diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs index 04ade7b7e..0aee87afd 100644 --- a/scripts/gentest/src/main.rs +++ b/scripts/gentest/src/main.rs @@ -232,7 +232,9 @@ fn generate_test(name: impl AsRef, description: &Value) -> TokenStream { taffy.print_tree(node); println!(); + let mut mismatches = 0u32; #assertions + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } ) } @@ -270,44 +272,50 @@ fn generate_assertions(ident: &str, node: &Value, use_rounding: bool) -> TokenSt let ident = Ident::new(ident, Span::call_site()); + let gen_check = |expr: TokenStream, expected: f32| { + let cmp = if use_rounding { + quote!(layout.#expr != #expected) + } else { + quote!((layout.#expr - #expected).abs() >= 0.1) + }; + quote!( + if #cmp { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", #ident, stringify!(#expr), #expected, layout.#expr); + } + ) + }; + // The scrollWidth reading from chrome is only accurate if the node is scroll container. So only assert in that case. // TODO: accurately test content size in the non-scroll-container case. - let scroll_assertions = if is_scroll_container { + let scroll_assertions = if is_scroll_container || true { + let check_scroll_width = gen_check(quote!(scroll_width()), scroll_width); + let check_scroll_height = gen_check(quote!(scroll_height()), scroll_height); quote!( #[cfg(feature = "content_size")] - assert_eq!(layout.scroll_width(), #scroll_width, "scroll_width of node {:?}. Expected {}. Actual {}", #ident, #scroll_width, layout.scroll_width()); + #check_scroll_width #[cfg(feature = "content_size")] - assert_eq!(layout.scroll_height(), #scroll_height, "scroll_height of node {:?}. Expected {}. Actual {}", #ident, #scroll_height, layout.scroll_height()); + #check_scroll_height ) } else { quote!() }; - if use_rounding { - quote!( - let layout = taffy.layout(#ident).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, #width, "width of node {:?}. Expected {}. Actual {}", #ident, #width, size.width); - assert_eq!(size.height, #height, "height of node {:?}. Expected {}. Actual {}", #ident, #height, size.height); - assert_eq!(location.x, #x, "x of node {:?}. Expected {}. Actual {}", #ident, #x, location.x); - assert_eq!(location.y, #y, "y of node {:?}. Expected {}. Actual {}", #ident, #y, location.y); - #scroll_assertions - - #children - ) - } else { - quote!( - let layout = taffy.layout(#ident).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - #width).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", #ident, #width, size.width); - assert!((size.height - #height).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", #ident, #height, size.height); - assert!((location.x - #x).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", #ident, #x, location.x); - assert!((location.y - #y).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", #ident, #y, location.y); - #scroll_assertions - - #children - ) - } + let check_width = gen_check(quote!(size.width), width); + let check_height = gen_check(quote!(size.height), height); + let check_x = gen_check(quote!(location.x), x); + let check_y = gen_check(quote!(location.y), y); + + quote!( + let layout = taffy.layout(#ident).unwrap(); + #check_width + #check_height + #check_x + #check_y + #scroll_assertions + + #children + ) } fn generate_node(ident: &str, node: &Value) -> TokenStream { @@ -439,27 +447,25 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { _ => quote!(), }; - fn quote_overflow(overflow: &Value) -> Option { + fn quote_overflow(overflow: &Value) -> (TokenStream, bool) { match overflow { Value::String(ref value) => match value.as_ref() { - "hidden" => Some(quote!(taffy::style::Overflow::Hidden)), - "scroll" => Some(quote!(taffy::style::Overflow::Scroll)), - "auto" => Some(quote!(taffy::style::Overflow::Auto)), - _ => None, + "hidden" => (quote!(taffy::style::Overflow::Hidden), true), + "scroll" => (quote!(taffy::style::Overflow::Scroll), true), + "auto" => (quote!(taffy::style::Overflow::Auto), true), + "clip" => (quote!(taffy::style::Overflow::Clip), false), + _ => (quote!(taffy::style::Overflow::Visible), false), }, - _ => None, + _ => (quote!(taffy::style::Overflow::Visible), false), } } - let overflow_x = quote_overflow(&style["overflowX"]); - let overflow_y = quote_overflow(&style["overflowY"]); - let (overflow, scrollbar_width) = if overflow_x.is_some() || overflow_y.is_some() { - let overflow_x = overflow_x.unwrap_or(quote!(taffy::style::Overflow::Visible)); - let overflow_y = overflow_y.unwrap_or(quote!(taffy::style::Overflow::Visible)); - let overflow = quote!(overflow: taffy::geometry::Point { x: #overflow_x, y: #overflow_y },); - let scrollbar_width = quote_number_prop("scrollbar_width", style, |value: f32| quote!(#value)); - (overflow, scrollbar_width) + let (overflow_x, x_scroll_container) = quote_overflow(&style["overflowX"]); + let (overflow_y, y_scroll_container) = quote_overflow(&style["overflowY"]); + let overflow = quote!(overflow: taffy::geometry::Point { x: #overflow_x, y: #overflow_y },); + let scrollbar_width = if x_scroll_container | y_scroll_container { + quote_number_prop("scrollbar_width", style, |value: f32| quote!(#value)) } else { - (quote!(), quote!()) + quote!() }; let text_align = match style["textAlign"] { @@ -610,7 +616,8 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { let text_content = get_string_value("text_content", node); let writing_mode = get_string_value("writingMode", style); let raw_aspect_ratio = get_number_value("aspect_ratio", style); - let node_context: Option<_> = text_content.map(|text| generate_node_context(text, writing_mode, raw_aspect_ratio)); + let node_context: Option<_> = + text_content.map(|text| generate_node_context(ident, text, writing_mode, raw_aspect_ratio)); edges_quoted!(style, margin, generate_length_percentage_auto, quote!(zero())); edges_quoted!(style, padding, generate_length_percentage, quote!(zero())); @@ -684,8 +691,11 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { #children_body let #ident = taffy.new_with_children(#style,#children).unwrap(); ) - } else if node_context.is_some() { - quote!(let #ident = taffy.new_leaf_with_context(#style,#node_context,).unwrap();) + } else if let Some((temps, expr)) = node_context { + quote!( + #temps + let #ident = taffy.new_leaf_with_context(#style,#expr,).unwrap(); + ) } else { quote!(let #ident = taffy.new_leaf(#style).unwrap();) } @@ -922,7 +932,12 @@ fn generate_scalar_definition(track_definition: &serde_json::Map) } } -fn generate_node_context(text_content: &str, writing_mode: Option<&str>, aspect_ratio: Option) -> TokenStream { +fn generate_node_context( + node_ident: &str, + text_content: &str, + writing_mode: Option<&str>, + aspect_ratio: Option, +) -> (TokenStream, TokenStream) { let trimmed_text_content = text_content.trim(); let writing_mode_token = match writing_mode { @@ -935,7 +950,20 @@ fn generate_node_context(text_content: &str, writing_mode: Option<&str>, aspect_ None => quote!(None), }; - quote!( - crate::TestNodeContext::ahem_text(#trimmed_text_content, #writing_mode_token) - ) + let string_lit = quote!(#trimmed_text_content); + + // If the string literal is too long, rustfmt gives up on the + // whole line. So pull long string literals out onto their own + // line so that the Style constructor still gets formatted. + if string_lit.to_string().len() > 100 { + let temp = format_ident!("{node_ident}_text"); + (quote!(let #temp = #string_lit;), quote!(crate::TestNodeContext::ahem_text(#temp, #writing_mode_token))) + } else { + ( + quote!(), + quote!( + crate::TestNodeContext::ahem_text(#string_lit, #writing_mode_token) + ), + ) + } } diff --git a/src/compute/block.rs b/src/compute/block.rs index 35f5be89f..a279894fd 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1,4 +1,6 @@ //! Computes the CSS block layout algorithm in the case that the block container being laid out contains only block-level boxes + +use crate::compute::common::compute_scrollbar_size; use crate::geometry::{Line, Point, Rect, Size}; use crate::style::{AvailableSpace, CoreStyle, LengthPercentageAuto, Overflow, Position}; use crate::style_helpers::TaffyMaxContent; @@ -12,7 +14,7 @@ use crate::util::{MaybeResolve, ResolveOrZero}; use crate::{BlockContainerStyle, BlockItemStyle, BoxGenerationMode, BoxSizing, LayoutBlockContainer, TextAlign}; #[cfg(feature = "content_size")] -use super::common::content_size::compute_content_size_contribution; +use super::common::content_size::expand_scrollable_overflow; /// Per-child data that is accumulated and modified over the course of the layout algorithm struct BlockItem { @@ -134,12 +136,13 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: let aspect_ratio = style.aspect_ratio(); let padding = raw_padding.resolve_or_zero(parent_size.width, |val, basis| tree.calc(val, basis)); let border = raw_border.resolve_or_zero(parent_size.width, |val, basis| tree.calc(val, basis)); + let overflow = style.overflow(); // Scrollbar gutters are reserved when the `overflow` property is set to `Overflow::Scroll`. // However, the axis are switched (transposed) because a node that scrolls vertically needs // *horizontal* space to be reserved for a scrollbar let scrollbar_gutter = { - let offsets = style.overflow().transpose().map(|overflow| match overflow { + let offsets = overflow.transpose().map(|overflow| match overflow { Overflow::Scroll => style.scrollbar_width(), _ => 0.0, }); @@ -169,25 +172,25 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: .maybe_apply_aspect_ratio(aspect_ratio) .maybe_add(box_sizing_adjustment); + // Is this a scroll container? + let is_scroll_container = overflow.x.is_scroll_container() || overflow.y.is_scroll_container(); + // Determine margin collapsing behaviour let own_margins_collapse_with_children = Line { start: vertical_margins_are_collapsible.start - && !style.overflow().x.is_scroll_container() - && !style.overflow().y.is_scroll_container() + && !is_scroll_container && style.position() == Position::Relative && padding.top == 0.0 && border.top == 0.0, end: vertical_margins_are_collapsible.end - && !style.overflow().x.is_scroll_container() - && !style.overflow().y.is_scroll_container() + && !is_scroll_container && style.position() == Position::Relative && padding.bottom == 0.0 && border.bottom == 0.0 && size.height.is_none(), }; let has_styles_preventing_being_collapsed_through = !style.is_block() - || style.overflow().x.is_scroll_container() - || style.overflow().y.is_scroll_container() + || is_scroll_container || style.position() == Position::Absolute || padding.top > 0.0 || padding.bottom > 0.0 @@ -220,7 +223,15 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: let resolved_padding = raw_padding.resolve_or_zero(Some(container_outer_width), |val, basis| tree.calc(val, basis)); let resolved_border = raw_border.resolve_or_zero(Some(container_outer_width), |val, basis| tree.calc(val, basis)); let resolved_content_box_inset = resolved_padding + resolved_border + scrollbar_gutter; - let (inflow_content_size, intrinsic_outer_height, first_child_top_margin_set, last_child_bottom_margin_set) = + + #[cfg(feature = "content_size")] + let scroll_origin = resolved_border.top_left(); + + // Accumulator for the descendent's scrollable overflow. + #[cfg(feature = "content_size")] + let mut descendent_scrollable_overflow = Rect::new_empty(); + + let (intrinsic_outer_height, first_child_top_margin_set, last_child_bottom_margin_set) = perform_final_layout_on_in_flow_children( tree, &mut items, @@ -229,7 +240,21 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: resolved_content_box_inset, text_align, own_margins_collapse_with_children, + #[cfg(feature = "content_size")] + &mut descendent_scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, ); + + // If we are a scroll container, inflate the inflow scrollable + // overflow by our padding. This only applys to inflow children + // so we do it here before adding the out-of-flow (absolute) + // children. + #[cfg(feature = "content_size")] + if is_scroll_container { + descendent_scrollable_overflow = descendent_scrollable_overflow.outset_by(resolved_padding); + } + let container_outer_height = known_dimensions .height .unwrap_or(intrinsic_outer_height.maybe_clamp(min_size.height, max_size.height)) @@ -244,9 +269,17 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: // 4. Layout absolutely positioned children let absolute_position_inset = resolved_border + scrollbar_gutter; let absolute_position_area = final_outer_size - absolute_position_inset.sum_axes(); - let absolute_position_offset = Point { x: absolute_position_inset.left, y: absolute_position_inset.top }; - let absolute_content_size = - perform_absolute_layout_on_absolute_children(tree, &items, absolute_position_area, absolute_position_offset); + let absolute_position_offset = absolute_position_inset.top_left(); + perform_absolute_layout_on_absolute_children( + tree, + &items, + absolute_position_area, + absolute_position_offset, + #[cfg(feature = "content_size")] + &mut descendent_scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, + ); // 5. Perform hidden layout on hidden children let len = tree.child_count(node_id); @@ -271,14 +304,10 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: let can_be_collapsed_through = !has_styles_preventing_being_collapsed_through && all_in_flow_children_can_be_collapsed_through; - #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] - let content_size = inflow_content_size.f32_max(absolute_content_size); - LayoutOutput { size: final_outer_size, #[cfg(feature = "content_size")] - content_size, - first_baselines: Point::NONE, + descendent_scrollable_overflow, top_margin: if own_margins_collapse_with_children.start { first_child_top_margin_set } else { @@ -293,6 +322,7 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs: CollapsibleMarginSet::from_margin(margin_bottom) }, margins_can_collapse_through: can_be_collapsed_through, + ..LayoutOutput::DEFAULT } } @@ -398,15 +428,15 @@ fn perform_final_layout_on_in_flow_children( resolved_content_box_inset: Rect, text_align: TextAlign, own_margins_collapse_with_children: Line, -) -> (Size, f32, CollapsibleMarginSet, CollapsibleMarginSet) { + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] container_scroll_origin: Point, +) -> (f32, CollapsibleMarginSet, CollapsibleMarginSet) { // Resolve container_inner_width for sizing child nodes using initial content_box_inset let container_inner_width = container_outer_width - content_box_inset.horizontal_axis_sum(); let parent_size = Size { width: Some(container_outer_width), height: None }; let available_space = Size { width: AvailableSpace::Definite(container_inner_width), height: AvailableSpace::MinContent }; - #[cfg_attr(not(feature = "content_size"), allow(unused_mut))] - let mut inflow_content_size = Size::ZERO; let mut committed_y_offset = resolved_content_box_inset.top; let mut y_offset_for_absolute = resolved_content_box_inset.top; let mut first_child_top_margin_set = CollapsibleMarginSet::ZERO; @@ -510,10 +540,20 @@ fn perform_final_layout_on_in_flow_children( } } - let scrollbar_size = Size { - width: if item.overflow.y == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - height: if item.overflow.x == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - }; + let scrollbar_size = compute_scrollbar_size( + item.overflow, + item_layout.size, + item.padding, + item.border, + item.scrollbar_width, + ); + + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add + // the resultant padding box to the scrollable overflow. + let scrollable_overflow = item_layout + .descendent_scrollable_overflow + .union(Rect::from_origin_and_size(item_layout.size).inset_by(item.border).shrunk_by(scrollbar_size)); tree.set_unrounded_layout( item.node_id, @@ -521,24 +561,27 @@ fn perform_final_layout_on_in_flow_children( order: item.order, size: item_layout.size, #[cfg(feature = "content_size")] - content_size: item_layout.content_size, + scrollable_overflow, scrollbar_size, location, padding: item.padding, border: item.border, margin: resolved_margin, + ..Layout::default() }, ); #[cfg(feature = "content_size")] - { - inflow_content_size = inflow_content_size.f32_max(compute_content_size_contribution( - location, - final_size, - item_layout.content_size, - item.overflow, - )); - } + expand_scrollable_overflow( + container_scrollable_overflow, + container_scroll_origin, + location, + final_size, + item.border, + scrollbar_size, + item.overflow, + scrollable_overflow, + ); // Update first_child_top_margin_set if is_collapsing_with_first_margin_set { @@ -572,7 +615,7 @@ fn perform_final_layout_on_in_flow_children( committed_y_offset += resolved_content_box_inset.bottom + bottom_y_margin_offset; let content_height = f32_max(0.0, committed_y_offset); - (inflow_content_size, content_height, first_child_top_margin_set, last_child_bottom_margin_set) + (content_height, first_child_top_margin_set, last_child_bottom_margin_set) } /// Perform absolute layout on all absolutely positioned children. @@ -582,13 +625,12 @@ fn perform_absolute_layout_on_absolute_children( items: &[BlockItem], area_size: Size, area_offset: Point, -) -> Size { + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] container_scroll_origin: Point, +) { let area_width = area_size.width; let area_height = area_size.height; - #[cfg_attr(not(feature = "content_size"), allow(unused_mut))] - let mut absolute_content_size = Size::ZERO; - for item in items.iter().filter(|item| item.position == Position::Absolute) { let child_style = tree.get_block_child_style(item.node_id); @@ -751,12 +793,15 @@ fn perform_absolute_layout_on_absolute_children( .maybe_add(area_offset.y) .unwrap_or(item.static_position.y + resolved_margin.top), }; - // Note: axis intentionally switched here as scrollbars take up space in the opposite axis - // to the axis in which scrolling is enabled. - let scrollbar_size = Size { - width: if item.overflow.y == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - height: if item.overflow.x == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - }; + + let scrollbar_size = compute_scrollbar_size(item.overflow, final_size, padding, border, item.scrollbar_width); + + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add the + // resultant padding box to the scrollable overflow. + let scrollable_overflow = layout_output + .descendent_scrollable_overflow + .union(Rect::from_top_left_and_size(border.top_left(), final_size - (border.sum_axes() + scrollbar_size))); tree.set_unrounded_layout( item.node_id, @@ -764,25 +809,26 @@ fn perform_absolute_layout_on_absolute_children( order: item.order, size: final_size, #[cfg(feature = "content_size")] - content_size: layout_output.content_size, + scrollable_overflow, scrollbar_size, location, padding, border, margin: resolved_margin, + ..Layout::default() }, ); #[cfg(feature = "content_size")] - { - absolute_content_size = absolute_content_size.f32_max(compute_content_size_contribution( - location, - final_size, - layout_output.content_size, - item.overflow, - )); - } + expand_scrollable_overflow( + container_scrollable_overflow, + container_scroll_origin, + location, + final_size, + border, + scrollbar_size, + item.overflow, + scrollable_overflow, + ); } - - absolute_content_size } diff --git a/src/compute/common/content_size.rs b/src/compute/common/content_size.rs index 8dfbfa87b..45ceb1b7d 100644 --- a/src/compute/common/content_size.rs +++ b/src/compute/common/content_size.rs @@ -1,32 +1,84 @@ //! Generic CSS content size code that is shared between all CSS algorithms. -use crate::geometry::{Point, Size}; +use crate::geometry::{Point, Rect, Size}; use crate::style::Overflow; -use crate::util::sys::f32_max; - -#[inline(always)] -/// Determine how much width/height a given node contributes to it's parent's content size -pub(crate) fn compute_content_size_contribution( - location: Point, - size: Size, - content_size: Size, - overflow: Point, -) -> Size { - let size_content_size_contribution = Size { - width: match overflow.x { - Overflow::Visible => f32_max(size.width, content_size.width), - _ => size.width, - }, - height: match overflow.y { - Overflow::Visible => f32_max(size.height, content_size.height), - _ => size.height, - }, - }; - if size_content_size_contribution.width > 0.0 && size_content_size_contribution.height > 0.0 { - Size { - width: location.x + size_content_size_contribution.width, - height: location.y + size_content_size_contribution.height, - } - } else { - Size::ZERO + +pub(crate) fn expand_scrollable_overflow( + container_scrollable_overflow: &mut Rect, + container_scroll_origin: Point, + + item_location: Point, + item_size: Size, + item_border: Rect, + item_scrollbar_gutter: Size, + item_overflow: Point, + item_scrollable_overflow: Rect, +) { + let item_rect = Rect::from_top_left_and_size(item_location, item_size); + + // From CSS Overflow 3, section 2.2: + // The scrollable overflow area is the union of: + // ... + // - The border boxes of all boxes for which it is the + // containing block and whose border boxes are positioned not + // wholly in the unreachable scrollable overflow region, + // accounting for transforms by projecting each box onto the + // plane of the element that establishes its 3D rendering + // context. [CSS3-TRANSFORMS] + if item_rect.right < container_scroll_origin.x || item_rect.bottom < container_scroll_origin.y { + return; + } + + // From CSS Overflow 3, section 2.2: + // The scrollable overflow area is the union of: + // ... + // Border boxes with zero area do not affect the scrollable + // overflow area. + if item_size.has_non_zero_area() { + container_scrollable_overflow.union_with(item_rect); + } + + // From CSS Overflow 3, section 2.2: + // The scrollable overflow area is the union of: + // ... + // - The margin areas of grid item and flex item boxes for + // which the box establishes a containing block. + + // TODO: open questions: + // - what does this mean? + // - is this predicated the same as the previous item? + // - assuming the margins are positive, don't this subsume the + // previous item? + + // From CSS Overflow 3, section 2.2: + // The scrollable overflow area is the union of: + // ... + // - The scrollable overflow areas of all of the above boxes + // (including zero-area boxes and accounting for + // transforms as described above), provided they + // themselves have overflow: visible (i.e. do not + // themselves trap the overflow) and that scrollable + // overflow is not already clipped (e.g. by the clip + // property or the contain property). + // + // TODO: Account for clip and contain properties. + + let item_clip_rect = item_rect.shrunk_by(item_scrollbar_gutter).inset_by(item_border); + + let mut positioned_overflow = item_scrollable_overflow.offset_by(item_location.into()); + + if match item_overflow { + Point { x: Overflow::Visible, y: Overflow::Visible } => true, + Point { x: Overflow::Visible, y: Overflow::Clip } => positioned_overflow.clip_against_y(item_clip_rect), + Point { x: Overflow::Clip, y: Overflow::Visible } => positioned_overflow.clip_against_x(item_clip_rect), + // From CSS Overflow 3, section 3.1: + // The visible/clip values of overflow compute to + // auto/hidden (respectively) if one of overflow-x or + // overflow-y is neither visible nor clip. + // + // Therefore all other pairs compute to auto, hidden, + // or clip--and hence do not have overflow: visible. + _ => false, + } { + container_scrollable_overflow.union_with(positioned_overflow); } } diff --git a/src/compute/common/mod.rs b/src/compute/common/mod.rs index d34eddb6d..4e976c016 100644 --- a/src/compute/common/mod.rs +++ b/src/compute/common/mod.rs @@ -1,5 +1,35 @@ //! Generic code that is shared between multiple layout algorithms + +use crate::{ + geometry::{Point, Rect, Size}, + style::Overflow, +}; + pub(crate) mod alignment; #[cfg(feature = "content_size")] pub(crate) mod content_size; + +/// Return the widths of the scrollbars present for the particular +/// `Overflow` factoring in that the scrollbars can't cause the +/// dimensions of the content rectange to go negative. +pub(crate) fn compute_scrollbar_size( + overflow: Point, + outer_size: Size, + padding: Rect, + border: Rect, + scrollbar_width: f32, +) -> Size { + // Earlier stuff is supposed to inflate outer_size enough to hold + // padding and border, but clamp the value at zero just in case. + let avail = outer_size - (padding + border).sum_axes().map(|val| val.max(0.0)); + // Scrollbars consume space on the perpendicular axis, hence the + // `.transpose()`. + Size::from(overflow.transpose()).zip_map(avail, |overflow, avail| { + if overflow == Overflow::Scroll { + avail.min(scrollbar_width) + } else { + 0.0 + } + }) +} diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs index 384e9f530..478ac236e 100644 --- a/src/compute/flexbox.rs +++ b/src/compute/flexbox.rs @@ -1,5 +1,8 @@ //! Computes the [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm on [`TaffyTree`](crate::TaffyTree) according to the [spec](https://www.w3.org/TR/css-flexbox-1/) -use crate::compute::common::alignment::compute_alignment_offset; +use crate::compute::common::{ + alignment::{apply_alignment_fallback, compute_alignment_offset}, + compute_scrollbar_size, +}; use crate::geometry::{Line, Point, Rect, Size}; use crate::style::{ AlignContent, AlignItems, AlignSelf, AvailableSpace, FlexWrap, JustifyContent, LengthPercentageAuto, Overflow, @@ -15,9 +18,8 @@ use crate::util::MaybeMath; use crate::util::{MaybeResolve, ResolveOrZero}; use crate::{BoxGenerationMode, BoxSizing}; -use super::common::alignment::apply_alignment_fallback; #[cfg(feature = "content_size")] -use super::common::content_size::compute_content_size_contribution; +use super::common::content_size::expand_scrollable_overflow; /// The intermediate results of a flexbox calculation for a single item struct FlexItem { @@ -135,11 +137,18 @@ struct AlgoConstants { margin: Rect, /// The border of this section border: Rect, + /// The padding of this section + #[cfg(feature = "content_size")] + padding: Rect, /// The space between the content box and the border box. /// This consists of padding + border + scrollbar_gutter. content_box_inset: Rect, + /// True iff this is a scroll container (i.e. either overflow + /// value is auto, scroll, or hidden). + #[cfg(feature = "content_size")] + is_scroll_container: bool, /// The size reserved for scrollbar gutters in each axis - scrollbar_gutter: Point, + scrollbar_gutter: Size, /// The gap of this section gap: Size, /// The align_items property of this node @@ -364,13 +373,56 @@ fn compute_preliminary(tree: &mut impl LayoutFlexboxContainer, node: NodeId, inp debug_log!("align_flex_lines_per_align_content"); align_flex_lines_per_align_content(&mut flex_lines, &constants, total_line_cross_size); + #[cfg(feature = "content_size")] + let padding_box = Rect::from_origin_and_size(constants.container_size) + .inset_by(constants.border) + .shrunk_by(constants.scrollbar_gutter); + + // The origin of the scrolling region. Nominally the upper-left + // of the padding box, but can be adjusted to accomodate + // `place-content: start` and `place-content: end` alignment. + // (That detail is not yet implemented.) + #[cfg(feature = "content_size")] + let scroll_origin: Point = padding_box.top_left(); + + // Accumulator for the scrollable content inherited from children. + // Adding our padding box only happens once our final size has + // been picked by the container we are inside. + #[cfg(feature = "content_size")] + let mut scrollable_overflow = Rect::new_empty(); + // Do a final layout pass and gather the resulting layouts debug_log!("final_layout_pass"); - let inflow_content_size = final_layout_pass(tree, &mut flex_lines, &constants); + final_layout_pass( + tree, + &mut flex_lines, + &constants, + #[cfg(feature = "content_size")] + &mut scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, + ); + + #[cfg(feature = "content_size")] + // If we are a scroll container, inflate the inflow scrollable + // overflow by our padding. This only applys to inflow children + // so we do it here before adding the out-of-flow (absolute) + // children. + if constants.is_scroll_container { + scrollable_overflow = scrollable_overflow.outset_by(constants.padding); + } // Before returning we perform absolute layout on all absolutely positioned children debug_log!("perform_absolute_layout_on_absolute_children"); - let absolute_content_size = perform_absolute_layout_on_absolute_children(tree, node, &constants); + perform_absolute_layout_on_absolute_children( + tree, + node, + &constants, + #[cfg(feature = "content_size")] + &mut scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, + ); debug_log!("hidden_layout"); let len = tree.child_count(node); @@ -407,7 +459,8 @@ fn compute_preliminary(tree: &mut impl LayoutFlexboxContainer, node: NodeId, inp LayoutOutput::from_sizes_and_baselines( constants.container_size, - inflow_content_size.f32_max(absolute_content_size), + #[cfg(feature = "content_size")] + scrollable_overflow, Point { x: None, y: first_vertical_baseline }, ) } @@ -438,17 +491,18 @@ fn compute_constants( let align_content = style.align_content().unwrap_or(AlignContent::Stretch); let justify_content = style.justify_content(); + let overflow = style.overflow(); + #[cfg(feature = "content_size")] + let is_scroll_container = overflow.x.is_scroll_container() | overflow.y.is_scroll_container(); // Scrollbar gutters are reserved when the `overflow` property is set to `Overflow::Scroll`. // However, the axis are switched (transposed) because a node that scrolls vertically needs // *horizontal* space to be reserved for a scrollbar - let scrollbar_gutter = style.overflow().transpose().map(|overflow| match overflow { + let scrollbar_gutter = Size::from(overflow.transpose().map(|overflow| match overflow { Overflow::Scroll => style.scrollbar_width(), _ => 0.0, - }); + })); // TODO: make side configurable based on the `direction` property - let mut content_box_inset = padding + border; - content_box_inset.right += scrollbar_gutter.x; - content_box_inset.bottom += scrollbar_gutter.y; + let content_box_inset = padding + border + Rect::from_origin_and_size(scrollbar_gutter); let node_outer_size = known_dimensions; let node_inner_size = node_outer_size.maybe_sub(content_box_inset.sum_axes()); @@ -475,8 +529,12 @@ fn compute_constants( .maybe_add(box_sizing_adjustment), margin, border, + #[cfg(feature = "content_size")] + padding, gap, content_box_inset, + #[cfg(feature = "content_size")] + is_scroll_container, scrollbar_gutter, align_items, align_content, @@ -1883,10 +1941,11 @@ fn calculate_flex_item( total_offset_main: &mut f32, total_offset_cross: f32, line_offset_cross: f32, - #[cfg(feature = "content_size")] total_content_size: &mut Size, container_size: Size, node_inner_size: Size>, direction: FlexDirection, + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] container_scroll_origin: Point, ) { let layout_output = tree.perform_child_layout( item.node, @@ -1896,12 +1955,7 @@ fn calculate_flex_item( SizingMode::ContentSize, Line::FALSE, ); - let LayoutOutput { - size, - #[cfg(feature = "content_size")] - content_size, - .. - } = layout_output; + let size = layout_output.size; let offset_main = *total_offset_main + item.offset_main @@ -1928,10 +1982,15 @@ fn calculate_flex_item( true => Point { x: offset_main, y: offset_cross }, false => Point { x: offset_cross, y: offset_main }, }; - let scrollbar_size = Size { - width: if item.overflow.y == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - height: if item.overflow.x == Overflow::Scroll { item.scrollbar_width } else { 0.0 }, - }; + + let scrollbar_size = compute_scrollbar_size(item.overflow, size, item.padding, item.border, item.scrollbar_width); + + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add the + // resultant padding box to the scrollable overflow. + let scrollable_overflow = layout_output + .descendent_scrollable_overflow + .union(Rect::from_origin_and_size(size).inset_by(item.border).shrunk_by(scrollbar_size)); tree.set_unrounded_layout( item.node, @@ -1939,22 +1998,29 @@ fn calculate_flex_item( order: item.order, size, #[cfg(feature = "content_size")] - content_size, + scrollable_overflow, scrollbar_size, location, padding: item.padding, border: item.border, margin: item.margin, + ..Layout::default() }, ); *total_offset_main += item.offset_main + item.margin.main_axis_sum(direction) + size.main(direction); #[cfg(feature = "content_size")] - { - *total_content_size = - total_content_size.f32_max(compute_content_size_contribution(location, size, content_size, item.overflow)); - } + expand_scrollable_overflow( + container_scrollable_overflow, + container_scroll_origin, + location, + size, + item.border, + scrollbar_size, + item.overflow, + scrollable_overflow, + ); } /// Calculates the layout line @@ -1963,11 +2029,12 @@ fn calculate_layout_line( tree: &mut impl LayoutFlexboxContainer, line: &mut FlexLine, total_offset_cross: &mut f32, - #[cfg(feature = "content_size")] content_size: &mut Size, container_size: Size, node_inner_size: Size>, padding_border: Rect, direction: FlexDirection, + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] container_scroll_origin: Point, ) { let mut total_offset_main = padding_border.main_start(direction); let line_offset_cross = line.offset_cross; @@ -1980,11 +2047,13 @@ fn calculate_layout_line( &mut total_offset_main, *total_offset_cross, line_offset_cross, - #[cfg(feature = "content_size")] - content_size, container_size, node_inner_size, direction, + #[cfg(feature = "content_size")] + container_scrollable_overflow, + #[cfg(feature = "content_size")] + container_scroll_origin, ); } } else { @@ -1995,11 +2064,13 @@ fn calculate_layout_line( &mut total_offset_main, *total_offset_cross, line_offset_cross, - #[cfg(feature = "content_size")] - content_size, container_size, node_inner_size, direction, + #[cfg(feature = "content_size")] + container_scrollable_overflow, + #[cfg(feature = "content_size")] + container_scroll_origin, ); } } @@ -2013,24 +2084,25 @@ fn final_layout_pass( tree: &mut impl LayoutFlexboxContainer, flex_lines: &mut [FlexLine], constants: &AlgoConstants, -) -> Size { + #[cfg(feature = "content_size")] scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] scroll_origin: Point, +) { let mut total_offset_cross = constants.content_box_inset.cross_start(constants.dir); - #[cfg_attr(not(feature = "content_size"), allow(unused_mut))] - let mut content_size = Size::ZERO; - if constants.is_wrap_reverse { for line in flex_lines.iter_mut().rev() { calculate_layout_line( tree, line, &mut total_offset_cross, - #[cfg(feature = "content_size")] - &mut content_size, constants.container_size, constants.node_inner_size, constants.content_box_inset, constants.dir, + #[cfg(feature = "content_size")] + scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, ); } } else { @@ -2039,20 +2111,17 @@ fn final_layout_pass( tree, line, &mut total_offset_cross, - #[cfg(feature = "content_size")] - &mut content_size, constants.container_size, constants.node_inner_size, constants.content_box_inset, constants.dir, + #[cfg(feature = "content_size")] + scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, ); } } - - content_size.width += constants.content_box_inset.right - constants.border.right - constants.scrollbar_gutter.x; - content_size.height += constants.content_box_inset.bottom - constants.border.bottom - constants.scrollbar_gutter.y; - - content_size } /// Perform absolute layout on all absolutely positioned children. @@ -2061,15 +2130,14 @@ fn perform_absolute_layout_on_absolute_children( tree: &mut impl LayoutFlexboxContainer, node: NodeId, constants: &AlgoConstants, -) -> Size { + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] scroll_origin: Point, +) { let container_width = constants.container_size.width; let container_height = constants.container_size.height; let inset_relative_size = constants.container_size - constants.border.sum_axes() - constants.scrollbar_gutter.into(); - #[cfg_attr(not(feature = "content_size"), allow(unused_mut))] - let mut content_size = Size::ZERO; - for order in 0..tree.child_count(node) { let child = tree.get_child_id(node, order); let child_style = tree.get_flexbox_child_style(child); @@ -2288,48 +2356,44 @@ fn perform_absolute_layout_on_absolute_children( true => Point { x: offset_main, y: offset_cross }, false => Point { x: offset_cross, y: offset_main }, }; - let scrollbar_size = Size { - width: if overflow.y == Overflow::Scroll { scrollbar_width } else { 0.0 }, - height: if overflow.x == Overflow::Scroll { scrollbar_width } else { 0.0 }, - }; + + let scrollbar_size = compute_scrollbar_size(overflow, final_size, padding, border, scrollbar_width); + + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add the + // resultant padding box to the scrollable overflow. + let scrollable_overflow = layout_output + .descendent_scrollable_overflow + .union(Rect::from_origin_and_size(final_size).inset_by(border).shrunk_by(scrollbar_size)); + tree.set_unrounded_layout( child, &Layout { order: order as u32, size: final_size, #[cfg(feature = "content_size")] - content_size: layout_output.content_size, + scrollable_overflow, scrollbar_size, location, padding, border, margin: resolved_margin, + ..Layout::default() }, ); #[cfg(feature = "content_size")] - { - let size_content_size_contribution = Size { - width: match overflow.x { - Overflow::Visible => f32_max(final_size.width, layout_output.content_size.width), - _ => final_size.width, - }, - height: match overflow.y { - Overflow::Visible => f32_max(final_size.height, layout_output.content_size.height), - _ => final_size.height, - }, - }; - if size_content_size_contribution.has_non_zero_area() { - let content_size_contribution = Size { - width: location.x + size_content_size_contribution.width, - height: location.y + size_content_size_contribution.height, - }; - content_size = content_size.f32_max(content_size_contribution); - } - } + expand_scrollable_overflow( + container_scrollable_overflow, + scroll_origin, + location, + final_size, + border, + scrollbar_size, + overflow, + scrollable_overflow, + ); } - - content_size } /// Computes the total space taken up by gaps in an axis given: diff --git a/src/compute/grid/alignment.rs b/src/compute/grid/alignment.rs index 68303f9bc..a983c6b22 100644 --- a/src/compute/grid/alignment.rs +++ b/src/compute/grid/alignment.rs @@ -1,15 +1,16 @@ //! Alignment of tracks and final positioning of items use super::types::GridTrack; use crate::compute::common::alignment::{apply_alignment_fallback, compute_alignment_offset}; +use crate::compute::common::compute_scrollbar_size; use crate::geometry::{InBothAbsAxis, Line, Point, Rect, Size}; -use crate::style::{AlignContent, AlignItems, AlignSelf, AvailableSpace, CoreStyle, GridItemStyle, Overflow, Position}; +use crate::style::{AlignContent, AlignItems, AlignSelf, AvailableSpace, CoreStyle, GridItemStyle, Position}; use crate::tree::{Layout, LayoutPartialTreeExt, NodeId, SizingMode}; use crate::util::sys::f32_max; use crate::util::{MaybeMath, MaybeResolve, ResolveOrZero}; +use crate::{BoxSizing, LayoutGridContainer}; #[cfg(feature = "content_size")] -use crate::compute::common::content_size::compute_content_size_contribution; -use crate::{BoxSizing, LayoutGridContainer}; +use crate::compute::common::content_size::expand_scrollable_overflow; /// Align the grid tracks within the grid according to the align-content (rows) or /// justify-content (columns) property. This only does anything if the size of the @@ -63,7 +64,10 @@ pub(super) fn align_and_position_item( grid_area: Rect, container_alignment_styles: InBothAbsAxis>, baseline_shim: f32, -) -> (Size, f32, f32) { + + #[cfg(feature = "content_size")] container_scrollable_overflow: &mut Rect, + #[cfg(feature = "content_size")] container_scroll_origin: Point, +) -> (f32, f32) { let grid_area_size = Size { width: grid_area.right - grid_area.left, height: grid_area.bottom - grid_area.top }; let style = tree.get_grid_child_style(node); @@ -209,12 +213,12 @@ pub(super) fn align_and_position_item( ); // Resolve final size - let Size { width, height } = Size { width, height }.unwrap_or(layout_output.size).maybe_clamp(min_size, max_size); + let size = Size { width, height }.unwrap_or(layout_output.size).maybe_clamp(min_size, max_size); let (x, x_margin) = align_item_within_area( Line { start: grid_area.left, end: grid_area.right }, justify_self.unwrap_or(alignment_styles.horizontal), - width, + size.width, position, inset_horizontal, margin.horizontal_components(), @@ -223,42 +227,53 @@ pub(super) fn align_and_position_item( let (y, y_margin) = align_item_within_area( Line { start: grid_area.top, end: grid_area.bottom }, align_self.unwrap_or(alignment_styles.vertical), - height, + size.height, position, inset_vertical, margin.vertical_components(), baseline_shim, ); - let scrollbar_size = Size { - width: if overflow.y == Overflow::Scroll { scrollbar_width } else { 0.0 }, - height: if overflow.x == Overflow::Scroll { scrollbar_width } else { 0.0 }, - }; + let scrollbar_size = compute_scrollbar_size(overflow, size, padding, border, scrollbar_width); let resolved_margin = Rect { left: x_margin.start, right: x_margin.end, top: y_margin.start, bottom: y_margin.end }; + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add the + // resultant padding box to the scrollable overflow. + let scrollable_overflow = layout_output + .descendent_scrollable_overflow + .union(Rect::from_origin_and_size(size).inset_by(border).shrunk_by(scrollbar_size)); + tree.set_unrounded_layout( node, &Layout { order, location: Point { x, y }, - size: Size { width, height }, + size, #[cfg(feature = "content_size")] - content_size: layout_output.content_size, + scrollable_overflow, scrollbar_size, padding, border, margin: resolved_margin, + ..Layout::default() }, ); #[cfg(feature = "content_size")] - let contribution = - compute_content_size_contribution(Point { x, y }, Size { width, height }, layout_output.content_size, overflow); - #[cfg(not(feature = "content_size"))] - let contribution = Size::ZERO; + expand_scrollable_overflow( + container_scrollable_overflow, + container_scroll_origin, + Point { x, y }, + size, + border, + scrollbar_size, + overflow, + scrollable_overflow, + ); - (contribution, y, height) + (y, size.height) } /// Align and size a grid item along a single axis diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs index a9a3ab089..8e3638831 100644 --- a/src/compute/grid/mod.rs +++ b/src/compute/grid/mod.rs @@ -82,10 +82,15 @@ pub fn compute_grid_layout( // Scrollbar gutters are reserved when the `overflow` property is set to `Overflow::Scroll`. // However, the axis are switched (transposed) because a node that scrolls vertically needs // *horizontal* space to be reserved for a scrollbar - let scrollbar_gutter = style.overflow().transpose().map(|overflow| match overflow { + let overflow = style.overflow(); + let scrollbar_gutter = overflow.transpose().map(|overflow| match overflow { Overflow::Scroll => style.scrollbar_width(), _ => 0.0, }); + + #[cfg(feature = "content_size")] + let is_scroll_container = overflow.x.is_scroll_container() | overflow.y.is_scroll_container(); + // TODO: make side configurable based on the `direction` property let mut content_box_inset = padding_border; content_box_inset.right += scrollbar_gutter.x; @@ -491,8 +496,14 @@ pub fn compute_grid_layout( // 9. Size, Align, and Position Grid Items - #[cfg_attr(not(feature = "content_size"), allow(unused_mut))] - let mut item_content_size_contribution = Size::ZERO; + #[cfg(feature = "content_size")] + let scroll_origin = border.top_left(); + + // Accumulator for the scrollable content inherited from children. + // Adding our padding box only happens once our final size has + // been picked by the container we are inside. + #[cfg(feature = "content_size")] + let mut scrollable_overflow = Rect::new_empty(); // Sort items back into original order to allow them to be matched up with styles items.sort_by_key(|item| item.source_order); @@ -507,22 +518,29 @@ pub fn compute_grid_layout( left: columns[item.column_indexes.start as usize + 1].offset, right: columns[item.column_indexes.end as usize].offset, }; - #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] - let (content_size_contribution, y_position, height) = align_and_position_item( + let (y_position, height) = align_and_position_item( tree, item.node, index as u32, grid_area, container_alignment_styles, item.baseline_shim, + #[cfg(feature = "content_size")] + &mut scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, ); item.y_position = y_position; item.height = height; + } - #[cfg(feature = "content_size")] - { - item_content_size_contribution = item_content_size_contribution.f32_max(content_size_contribution); - } + // If we are a scroll container, inflate the inflow scrollable + // overflow by our padding. This only applys to inflow children + // so we do it here before adding the out-of-flow (absolute) + // children. + #[cfg(feature = "content_size")] + if is_scroll_container { + scrollable_overflow = scrollable_overflow.outset_by(padding); } // Position hidden and absolutely positioned children @@ -583,13 +601,18 @@ pub fn compute_grid_layout( drop(child_style); // TODO: Baseline alignment support for absolutely positioned items (should check if is actually specified) - #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] - let (content_size_contribution, _, _) = - align_and_position_item(tree, child, order, grid_area, container_alignment_styles, 0.0); - #[cfg(feature = "content_size")] - { - item_content_size_contribution = item_content_size_contribution.f32_max(content_size_contribution); - } + align_and_position_item( + tree, + child, + order, + grid_area, + container_alignment_styles, + 0.0, + #[cfg(feature = "content_size")] + &mut scrollable_overflow, + #[cfg(feature = "content_size")] + scroll_origin, + ); order += 1; } @@ -608,7 +631,11 @@ pub fn compute_grid_layout( // If there are not items then return just the container size (no baseline) if items.is_empty() { - return LayoutOutput::from_outer_size(container_border_box); + return LayoutOutput::from_size_and_overflow( + container_border_box, + #[cfg(feature = "content_size")] + scrollable_overflow, + ); } // Determine the grid container baseline(s) (currently we only compute the first baseline) @@ -636,7 +663,8 @@ pub fn compute_grid_layout( LayoutOutput::from_sizes_and_baselines( container_border_box, - item_content_size_contribution, + #[cfg(feature = "content_size")] + scrollable_overflow, Point { x: None, y: Some(grid_container_baseline) }, ) } diff --git a/src/compute/leaf.rs b/src/compute/leaf.rs index 4f1d979cd..fd89cc0a0 100644 --- a/src/compute/leaf.rs +++ b/src/compute/leaf.rs @@ -1,8 +1,8 @@ //! Computes size using styles and measure functions -use crate::geometry::{Point, Size}; +use crate::geometry::Size; use crate::style::{AvailableSpace, Overflow, Position}; -use crate::tree::{CollapsibleMarginSet, RunMode}; +use crate::tree::RunMode; use crate::tree::{LayoutInput, LayoutOutput, SizingMode}; use crate::util::debug::debug_log; use crate::util::sys::f32_max; @@ -11,6 +11,9 @@ use crate::util::{MaybeResolve, ResolveOrZero}; use crate::{BoxSizing, CoreStyle}; use core::unreachable; +#[cfg(feature = "content_size")] +use crate::geometry::Rect; + /// Compute the size of a leaf node (node with no children) pub fn compute_leaf_layout( inputs: LayoutInput, @@ -64,7 +67,9 @@ where // Scrollbar gutters are reserved when the `overflow` property is set to `Overflow::Scroll`. // However, the axis are switched (transposed) because a node that scrolls vertically needs // *horizontal* space to be reserved for a scrollbar - let scrollbar_gutter = style.overflow().transpose().map(|overflow| match overflow { + let overflow = style.overflow(); + let is_scroll_container = overflow.x.is_scroll_container() || overflow.y.is_scroll_container(); + let scrollbar_gutter = overflow.transpose().map(|overflow| match overflow { Overflow::Scroll => style.scrollbar_width(), _ => 0.0, }); @@ -74,8 +79,7 @@ where content_box_inset.bottom += scrollbar_gutter.y; let has_styles_preventing_being_collapsed_through = !style.is_block() - || style.overflow().x.is_scroll_container() - || style.overflow().y.is_scroll_container() + || is_scroll_container || style.position() == Position::Absolute || padding.top > 0.0 || padding.bottom > 0.0 @@ -95,16 +99,8 @@ where let size = Size { width, height } .maybe_clamp(node_min_size, node_max_size) .maybe_max(padding_border.sum_axes().map(Some)); - return LayoutOutput { - size, - #[cfg(feature = "content_size")] - content_size: Size::ZERO, - first_baselines: Point::NONE, - top_margin: CollapsibleMarginSet::ZERO, - bottom_margin: CollapsibleMarginSet::ZERO, - margins_can_collapse_through: false, - }; - }; + return LayoutOutput { size, ..LayoutOutput::DEFAULT }; + } } // Compute available space @@ -148,17 +144,22 @@ where width: clamped_size.width, height: f32_max(clamped_size.height, aspect_ratio.map(|ratio| clamped_size.width / ratio).unwrap_or(0.0)), }; - let size = size.maybe_max(padding_border.sum_axes().map(Some)); + let size = size.f32_max(padding_border.sum_axes()); + + #[cfg(feature = "content_size")] + let descendent_scrollable_overflow = if is_scroll_container { + Rect::from_top_left_and_size(border.top_left(), measured_size + padding.sum_axes()) + } else { + Rect::from_top_left_and_size(border.top_left() + padding.top_left(), measured_size) + }; LayoutOutput { size, #[cfg(feature = "content_size")] - content_size: measured_size + padding.sum_axes(), - first_baselines: Point::NONE, - top_margin: CollapsibleMarginSet::ZERO, - bottom_margin: CollapsibleMarginSet::ZERO, + descendent_scrollable_overflow, margins_can_collapse_through: !has_styles_preventing_being_collapsed_through && size.height == 0.0 && measured_size.height == 0.0, + ..LayoutOutput::DEFAULT } } diff --git a/src/compute/mod.rs b/src/compute/mod.rs index aeb5a5f3e..dff0874bc 100644 --- a/src/compute/mod.rs +++ b/src/compute/mod.rs @@ -45,7 +45,7 @@ pub use self::flexbox::compute_flexbox_layout; pub use self::grid::compute_grid_layout; use crate::geometry::{Line, Point, Size}; -use crate::style::{AvailableSpace, CoreStyle, Overflow}; +use crate::style::{AvailableSpace, CoreStyle}; use crate::tree::{ Layout, LayoutInput, LayoutOutput, LayoutPartialTree, LayoutPartialTreeExt, NodeId, RoundTree, SizingMode, }; @@ -54,6 +54,9 @@ use crate::util::sys::round; use crate::util::ResolveOrZero; use crate::{CacheTree, MaybeMath, MaybeResolve}; +#[cfg(feature = "content_size")] +use crate::geometry::Rect; + /// Compute layout for the root node in the tree pub fn compute_root_layout(tree: &mut impl LayoutPartialTree, root: NodeId, available_space: Size) { let mut known_dimensions = Size::NONE; @@ -131,12 +134,17 @@ pub fn compute_root_layout(tree: &mut impl LayoutPartialTree, root: NodeId, avai style.border().resolve_or_zero(available_space.width.into_option(), |val, basis| tree.calc(val, basis)); let margin = style.margin().resolve_or_zero(available_space.width.into_option(), |val, basis| tree.calc(val, basis)); - let scrollbar_size = Size { - width: if style.overflow().y == Overflow::Scroll { style.scrollbar_width() } else { 0.0 }, - height: if style.overflow().x == Overflow::Scroll { style.scrollbar_width() } else { 0.0 }, - }; + let scrollbar_size = + common::compute_scrollbar_size(style.overflow(), output.size, padding, border, style.scrollbar_width()); drop(style); + #[cfg(feature = "content_size")] + // Now that we've picked a final size for the item, add the + // resultant padding box to the scrollable overflow. + let scrollable_overflow = output + .descendent_scrollable_overflow + .union(Rect::from_origin_and_size(output.size).inset_by(border).shrunk_by(scrollbar_size)); + tree.set_unrounded_layout( root, &Layout { @@ -144,12 +152,13 @@ pub fn compute_root_layout(tree: &mut impl LayoutPartialTree, root: NodeId, avai location: Point::ZERO, size: output.size, #[cfg(feature = "content_size")] - content_size: output.content_size, + scrollable_overflow, scrollbar_size, padding, border, // TODO: support auto margins for root node? margin, + ..Layout::default() }, ); } @@ -187,6 +196,8 @@ where tree.cache_store(node, known_dimensions, available_space, run_mode, computed_size_and_baselines); debug_log!("RESULT", dbg:computed_size_and_baselines.size); + #[cfg(feature = "content_size")] + debug_log!(" scrollable overflow", dbg:computed_size_and_baselines.descendent_scrollable_overflow); debug_pop_node!(); computed_size_and_baselines @@ -235,7 +246,7 @@ pub fn round_layout(tree: &mut impl RoundTree, node_id: NodeId) { - round(cumulative_y + unrounded_layout.size.height - unrounded_layout.padding.bottom); #[cfg(feature = "content_size")] - round_content_size(&mut layout, unrounded_layout.content_size, cumulative_x, cumulative_y); + round_scrollable_overflow(&mut layout, unrounded_layout.scrollable_overflow, cumulative_x, cumulative_y); tree.set_final_layout(node_id, &layout); @@ -248,16 +259,21 @@ pub fn round_layout(tree: &mut impl RoundTree, node_id: NodeId) { #[cfg(feature = "content_size")] #[inline(always)] - /// Round content size variables. - /// This is split into a separate function to make it easier to feature flag. - fn round_content_size( + /// Round the scrollable overflow. This is split into a separate + /// function to make it easier to feature flag. + fn round_scrollable_overflow( layout: &mut Layout, - unrounded_content_size: Size, + unrounded_scrollable_overflow: Rect, cumulative_x: f32, cumulative_y: f32, ) { - layout.content_size.width = round(cumulative_x + unrounded_content_size.width) - round(cumulative_x); - layout.content_size.height = round(cumulative_y + unrounded_content_size.height) - round(cumulative_y); + layout.scrollable_overflow.left = + round(cumulative_x + unrounded_scrollable_overflow.left) - round(cumulative_x); + layout.scrollable_overflow.right = + round(cumulative_x + unrounded_scrollable_overflow.right) - round(cumulative_x); + layout.scrollable_overflow.top = round(cumulative_y + unrounded_scrollable_overflow.top) - round(cumulative_y); + layout.scrollable_overflow.bottom = + round(cumulative_y + unrounded_scrollable_overflow.bottom) - round(cumulative_y); } } diff --git a/src/geometry.rs b/src/geometry.rs index 8cabefcf2..7d209e9b4 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -1,9 +1,13 @@ //! Geometric primitives useful for layout -use crate::util::sys::f32_max; -use crate::CompactLength; -use crate::{style::Dimension, util::sys::f32_min}; -use core::ops::{Add, Sub}; +use crate::{ + style::Dimension, + style_helpers::TaffyZero, + util::sys::{f32_max, f32_min}, + CompactLength, +}; + +use core::ops::{Add, Neg, Sub}; #[cfg(feature = "flexbox")] use crate::style::FlexDirection; @@ -139,7 +143,80 @@ impl> Add> for Rect { } } +impl> Sub> for Rect { + type Output = Rect; + + fn sub(self, rhs: Rect) -> Self::Output { + Rect { + left: self.left - rhs.left, + right: self.right - rhs.right, + top: self.top - rhs.top, + bottom: self.bottom - rhs.bottom, + } + } +} + +impl + Copy> Rect { + /// Create a rectangle when given the top left as a point and a + /// size. Right and bottom are the sum of the top_left and the + /// size. + pub fn from_top_left_and_size(top_left: Point, size: Size) -> Rect { + Rect { left: top_left.x, top: top_left.y, right: top_left.x + size.width, bottom: top_left.y + size.height } + } +} + +impl Rect { + /// Create a rectangle from the origin (i.e. left=0, top=0) with + /// the given size (i.e. right=width, bottom=height). + pub fn from_origin_and_size(size: Size) -> Rect { + Rect { left: T::ZERO, top: T::ZERO, right: size.width, bottom: size.height } + } +} + +impl + Copy> Rect { + /// Return the width of the rectangle (i.e. right - left). Only + /// valid if the Rect represents a rectangle area, not boundry + /// insets. + #[inline(always)] + pub fn width(&self) -> >::Output { + self.right - self.left + } + + /// Return the height of the rectangle (i.e. bottom - top). Only + /// valid if the Rect represents a rectangle area, not boundry + /// insets. + #[inline(always)] + pub fn height(self) -> >::Output { + self.bottom - self.top + } + + /// Return the width (i.e. right - left) and height (i.e. bottom - + /// top) of the rectangle as a Size. Only valid if the Rect + /// represents a rectangle area, not boundry insets. + #[inline(always)] + pub fn size(self) -> Size<>::Output> { + Size { width: self.width(), height: self.height() } + } +} + +impl Neg for Rect { + type Output = Rect<::Output>; + fn neg(self) -> Self::Output { + Rect { left: -self.left, right: -self.right, top: -self.top, bottom: -self.bottom } + } +} + impl Rect { + /// Returns the top and left components as a point. + pub fn top_left(self) -> Point { + Point { x: self.left, y: self.top } + } + + /// Returns the bottom and right components as a point. + pub fn bottom_right(self) -> Point { + Point { x: self.right, y: self.bottom } + } + /// Applies the function `f` to all four sides of the rect /// /// When applied to the left and right sides, the width is used @@ -178,6 +255,61 @@ impl Rect { pub fn vertical_components(self) -> Line { Line { start: self.top, end: self.bottom } } + + /// Return the rectangle with the edges moved "in" by the + /// corresponding component of `insets`. + pub fn inset_by(self, insets: Rect) -> Rect + where + T: Add, + T: Sub, + { + Rect { + left: self.left + insets.left, + right: self.right - insets.right, + top: self.top + insets.top, + bottom: self.bottom - insets.bottom, + } + } + + /// Return the rectangle with the edges moved "out" by the + /// corresponding component of `insets`. + pub fn outset_by(self, outsets: Rect) -> Rect + where + T: Add, + T: Sub, + { + Rect { + left: self.left - outsets.left, + right: self.right + outsets.right, + top: self.top - outsets.top, + bottom: self.bottom + outsets.bottom, + } + } + + /// Returns the rectangle with the horizontal components offset + /// by size.width and the vertical components offset by + /// size.height. + pub fn offset_by(self, displacement: Size) -> Rect<>::Output> + where + T: Add, + U: Copy, + { + Rect { + left: self.left + displacement.width, + right: self.right + displacement.width, + top: self.top + displacement.height, + bottom: self.bottom + displacement.height, + } + } + + /// Returns the rectangle with the bottom and right decreased by + /// the given delta. + pub fn shrunk_by(self, delta: Size) -> Rect + where + T: Sub, + { + Rect { left: self.left, right: self.right - delta.width, top: self.top, bottom: self.bottom - delta.height } + } } impl Rect @@ -296,6 +428,86 @@ impl Rect { pub const fn new(start: f32, end: f32, top: f32, bottom: f32) -> Self { Self { left: start, right: end, top, bottom } } + + /// Returns an "empty" rectangle with the left and top at positive + /// infinity and the right and bottom at negative infinity. This + /// is the identity element for union operations. + pub const fn new_empty() -> Self { + Self { left: f32::INFINITY, right: f32::NEG_INFINITY, top: f32::INFINITY, bottom: f32::NEG_INFINITY } + } + + /// Returns the union of self and `other`--the rectangle that + /// encloses all of the area of either rectangle. If `other` is + /// empty (i.e. right < left or bottom < top), returns self + /// unchanged. A rectangle with zero area (i.e. left==right or + /// top==bottom) is **not** excluded. In other words, the edges + /// are considered to be closed bounds. + /// + /// See also [`union_with`] + pub fn union(mut self, other: Rect) -> Rect { + self.union_with(other); + self + } + + /// Expands self to include the area of another rectangle. If + /// `other` is empty (i.e. right < left or bottom < top), leaves + /// self unchanged. A rectangle with zero area (i.e. left==right + /// or top==bottom) is **not** excluded. In other words, the + /// edges are considered to be closed bounds. + /// + pub fn union_with(&mut self, other: Rect) { + if other.left <= other.right && other.top <= other.bottom { + self.left = f32_min(self.left, other.left); + self.right = f32_max(self.right, other.right); + self.top = f32_min(self.top, other.top); + self.bottom = f32_max(self.bottom, other.bottom); + } + } + + /// Clip self against other along the X axis. Returns true iff + /// there is any overlap. Upon return, self will be within other + /// irrespective of the return value. + pub fn clip_against_x(&mut self, other: Rect) -> bool { + if self.right <= other.left { + self.left = other.left; + self.right = other.left; + false + } else if self.left >= other.right { + self.left = other.right; + self.right = other.right; + false + } else { + self.left = f32_max(self.left, other.left); + self.right = f32_min(self.right, other.right); + true + } + } + /// Clip self against other along the Y axis. Returns true iff + /// there is any overlap. Upon return, self will be within other + /// irrespective of the return value. + pub fn clip_against_y(&mut self, other: Rect) -> bool { + if self.bottom <= other.top { + self.top = other.top; + self.bottom = other.top; + false + } else if self.top >= other.bottom { + self.top = other.bottom; + self.bottom = other.bottom; + false + } else { + self.top = f32_max(self.top, other.top); + self.bottom = f32_min(self.bottom, other.bottom); + true + } + } + /// Clip self against other along the both axes. Returns true iff + /// there is any overlap. Upon return, self will be within other + /// irrespective of the return value. + pub fn clip_against(&mut self, other: Rect) -> bool { + let x = self.clip_against_x(other); + let y = self.clip_against_y(other); + x && y + } } /// An abstract "line". Represents any type that has a start and an end @@ -643,15 +855,34 @@ impl Point> { pub const NONE: Self = Self { x: None, y: None }; } -// Generic Add impl for Point + Point where T + U has an Add impl impl> Add> for Point { type Output = Point<>::Output>; + /// Generic Add impl for Point + Point where T + U has an Add impl fn add(self, rhs: Point) -> Self::Output { Point { x: self.x + rhs.x, y: self.y + rhs.y } } } +impl> Add> for Point { + type Output = Point<>::Output>; + + /// Adding a Size to a Point offsets the Point by the size. + fn add(self, rhs: Size) -> Self::Output { + Point { x: self.x + rhs.width, y: self.y + rhs.height } + } +} + +impl> Sub> for Point { + type Output = Size<>::Output>; + + /// Subtracting one point from another returns the distance between + /// them as a size. + fn sub(self, rhs: Point) -> Self::Output { + Size { width: self.x - rhs.x, height: self.y - rhs.y } + } +} + impl Point { /// Applies the function `f` to both the x and y /// @@ -687,30 +918,6 @@ impl Point { AbstractAxis::Block => self.y = value, } } - - /// Gets the component in the main layout axis - /// - /// Whether this is the x or y depends on the `direction` provided - #[cfg(feature = "flexbox")] - pub(crate) fn main(self, direction: FlexDirection) -> T { - if direction.is_row() { - self.x - } else { - self.y - } - } - - /// Gets the component in the cross layout axis - /// - /// Whether this is the x or y depends on the `direction` provided - #[cfg(feature = "flexbox")] - pub(crate) fn cross(self, direction: FlexDirection) -> T { - if direction.is_row() { - self.y - } else { - self.x - } - } } impl From> for Size { diff --git a/src/tree/layout.rs b/src/tree/layout.rs index 84a68505f..b6503b1f5 100644 --- a/src/tree/layout.rs +++ b/src/tree/layout.rs @@ -161,9 +161,15 @@ impl LayoutInput { pub struct LayoutOutput { /// The size of the node pub size: Size, - #[cfg(feature = "content_size")] - /// The size of the content within the node - pub content_size: Size, + /// The scrollable overflow from child elements and leaf content + /// measures. It does not include this node's own padding box, + /// because the exact dimensions of this node's final size (and + /// hence its border box) are at the whims of whoever called + /// perform_child_layout(). + /// + /// This field will be Rect::new_empty() unless the `content_size` + /// feature is enabled. + pub descendent_scrollable_overflow: Rect, /// The first baseline of the node in each dimension, if any pub first_baselines: Point>, /// Top margin that can be collapsed with. This is used for CSS block layout and can be set to @@ -181,8 +187,7 @@ impl LayoutOutput { /// An all-zero `LayoutOutput` for hidden nodes pub const HIDDEN: Self = Self { size: Size::ZERO, - #[cfg(feature = "content_size")] - content_size: Size::ZERO, + descendent_scrollable_overflow: Rect::new_empty(), first_baselines: Point::NONE, top_margin: CollapsibleMarginSet::ZERO, bottom_margin: CollapsibleMarginSet::ZERO, @@ -195,28 +200,37 @@ impl LayoutOutput { /// Constructor to create a `LayoutOutput` from just the size and baselines pub fn from_sizes_and_baselines( size: Size, - #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] content_size: Size, + #[cfg(feature = "content_size")] + descendent_scrollable_overflow: Rect, first_baselines: Point>, ) -> Self { Self { size, #[cfg(feature = "content_size")] - content_size, + descendent_scrollable_overflow, first_baselines, - top_margin: CollapsibleMarginSet::ZERO, - bottom_margin: CollapsibleMarginSet::ZERO, - margins_can_collapse_through: false, + ..Self::DEFAULT } } - /// Construct a `LayoutOutput` from just the container and content sizes - pub fn from_sizes(size: Size, content_size: Size) -> Self { - Self::from_sizes_and_baselines(size, content_size, Point::NONE) + /// Construct a `LayoutOutput` from just the container size and + /// scrollable overflow. + pub fn from_size_and_overflow( + size: Size, + #[cfg(feature = "content_size")] + descendent_scrollable_overflow: Rect, + ) -> Self { + Self { + size, + #[cfg(feature = "content_size")] + descendent_scrollable_overflow, + ..Self::DEFAULT + } } /// Construct a `LayoutOutput` from just the container's size. pub fn from_outer_size(size: Size) -> Self { - Self::from_sizes(size, Size::zero()) + Self { size, ..Self::DEFAULT } } } @@ -233,10 +247,14 @@ pub struct Layout { pub location: Point, /// The width and height of the node pub size: Size, - #[cfg(feature = "content_size")] - /// The width and height of the content inside the node. This may be larger than the size of the node in the case of - /// overflowing content and is useful for computing a "scroll width/height" for scrollable nodes - pub content_size: Size, + /// The extent of the scrollable overflow from this node and any + /// (unclipped) descendents. This will always include this node's + /// padding box and additionally includes the overflow from any + /// children that are not themselves clipped. + /// + /// This field will be Rect::zero() unless the `content_size` + /// feature is enabled. + pub scrollable_overflow: Rect, /// The size of the scrollbars in each dimension. If there is no scrollbar then the size will be zero. pub scrollbar_size: Size, /// The size of the borders of the node @@ -265,8 +283,7 @@ impl Layout { order: 0, location: Point::ZERO, size: Size::zero(), - #[cfg(feature = "content_size")] - content_size: Size::zero(), + scrollable_overflow: Rect::zero(), scrollbar_size: Size::zero(), border: Rect::zero(), padding: Rect::zero(), @@ -284,8 +301,7 @@ impl Layout { order, size: Size::zero(), location: Point::ZERO, - #[cfg(feature = "content_size")] - content_size: Size::zero(), + scrollable_overflow: Rect::zero(), scrollbar_size: Size::zero(), border: Rect::zero(), padding: Rect::zero(), @@ -324,24 +340,34 @@ impl Layout { #[cfg(feature = "content_size")] impl Layout { - /// Return the scroll width of the node. - /// The scroll width is the difference between the width and the content width, floored at zero + /// Return the scroll width of the node. The scroll width is the + /// difference between the padding box width and the portion of + /// the scrollable overflow to the right of the scroll origin. + /// Taffy assumes that the scroll origin is always the padding box's + /// top-left corner but there are unimplemented parts of the CSS + /// standard that cause it to move. pub fn scroll_width(&self) -> f32 { - f32_max( - 0.0, - self.content_size.width + f32_min(self.scrollbar_size.width, self.size.width) - self.size.width - + self.border.right, - ) + let right_padding_edge = + f32_max(self.size.width - self.border.right - self.scrollbar_size.width, self.border.left); + // The scrollable overflow always include the node's padding + // box, so this can never result in a negative value. + assert!(self.scrollable_overflow.right >= right_padding_edge); + return self.scrollable_overflow.right - right_padding_edge; } - /// Return the scroll height of the node. - /// The scroll height is the difference between the height and the content height, floored at zero + /// Return the scroll height of the node. The scroll height is + /// the difference between the padding box height and the portion + /// of the scrollable overflow below the top padding edge. Taffy + /// assumes that the scroll origin is always the padding box's + /// top-left corner but there are unimplemented parts of the CSS + /// standard that cause it to move. pub fn scroll_height(&self) -> f32 { - f32_max( - 0.0, - self.content_size.height + f32_min(self.scrollbar_size.height, self.size.height) - self.size.height - + self.border.bottom, - ) + let bottom_padding_edge = + f32_max(self.size.height - self.border.bottom - self.scrollbar_size.height, self.border.top); + // The scrollable overflow always include the node's padding + // box, so this can never result in a negative value. + assert!(self.scrollable_overflow.bottom >= bottom_padding_edge); + return self.scrollable_overflow.bottom - bottom_padding_edge; } } diff --git a/src/util/print.rs b/src/util/print.rs index 4d2fa3961..5e95985d3 100644 --- a/src/util/print.rs +++ b/src/util/print.rs @@ -15,26 +15,32 @@ pub fn print_tree(tree: &impl PrintTree, root: NodeId) { let fork_string = if has_sibling { "├── " } else { "└── " }; #[cfg(feature = "content_size")] println!( - "{lines}{fork} {display} [x: {x:<4} y: {y:<4} w: {width:<4} h: {height:<4} content_w: {content_width:<4} content_h: {content_height:<4} border: l:{bl} r:{br} t:{bt} b:{bb}, padding: l:{pl} r:{pr} t:{pt} b:{pb}] ({key:?})", - lines = lines_string, - fork = fork_string, - display = display, - x = layout.location.x, - y = layout.location.y, - width = layout.size.width, - height = layout.size.height, - content_width = layout.content_size.width, - content_height = layout.content_size.height, - bl = layout.border.left, - br = layout.border.right, - bt = layout.border.top, - bb = layout.border.bottom, - pl = layout.padding.left, - pr = layout.padding.right, - pt = layout.padding.top, - pb = layout.padding.bottom, - key = node_id, - ); + "{lines}{fork} {display} [x: {x:<4} y: {y:<4} w: {width:<4} h: {height:<4} scroll_w: {scroll_width:<4} scroll_h: {scroll_height:<4} border: l:{bl} r:{br} t:{bt} b:{bb}, padding: l:{pl} r:{pr} t:{pt} b:{pb} scrollbar: w:{sbw} h:{sbh} scrollable_overflow: x:{sol}..{sor} y: {sot}..{sob}] ({key:?})", + lines = lines_string, + fork = fork_string, + display = display, + x = layout.location.x, + y = layout.location.y, + width = layout.size.width, + height = layout.size.height, + scroll_width = layout.scroll_width(), + scroll_height = layout.scroll_height(), + bl = layout.border.left, + br = layout.border.right, + bt = layout.border.top, + bb = layout.border.bottom, + pl = layout.padding.left, + pr = layout.padding.right, + pt = layout.padding.top, + pb = layout.padding.bottom, + sbw = layout.scrollbar_size.width, + sbh = layout.scrollbar_size.height, + sol = layout.scrollable_overflow.left, + sor = layout.scrollable_overflow.right, + sot = layout.scrollable_overflow.top, + sob = layout.scrollable_overflow.bottom, + key = node_id, + ); #[cfg(not(feature = "content_size"))] println!( "{lines}{fork} {display} [x: {x:<4} y: {y:<4} width: {width:<4} height: {height:<4}] ({key:?})", diff --git a/test_fixtures/block/block_absolute_overflow_clip.html b/test_fixtures/block/block_absolute_overflow_clip.html new file mode 100644 index 000000000..8f6118ace --- /dev/null +++ b/test_fixtures/block/block_absolute_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_absolute_overflow_hidden.html b/test_fixtures/block/block_absolute_overflow_hidden.html new file mode 100644 index 000000000..3b16f3ca3 --- /dev/null +++ b/test_fixtures/block/block_absolute_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_absolute_overflow_scroll.html b/test_fixtures/block/block_absolute_overflow_scroll.html new file mode 100644 index 000000000..6b0749c4e --- /dev/null +++ b/test_fixtures/block/block_absolute_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_absolute_overflow_visible.html b/test_fixtures/block/block_absolute_overflow_visible.html new file mode 100644 index 000000000..504723e16 --- /dev/null +++ b/test_fixtures/block/block_absolute_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_inflow_overflow_clip.html b/test_fixtures/block/block_inflow_overflow_clip.html new file mode 100644 index 000000000..48430c63e --- /dev/null +++ b/test_fixtures/block/block_inflow_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_inflow_overflow_hidden.html b/test_fixtures/block/block_inflow_overflow_hidden.html new file mode 100644 index 000000000..3bc38d0c6 --- /dev/null +++ b/test_fixtures/block/block_inflow_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_inflow_overflow_scroll.html b/test_fixtures/block/block_inflow_overflow_scroll.html new file mode 100644 index 000000000..3ff35571a --- /dev/null +++ b/test_fixtures/block/block_inflow_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/block/block_inflow_overflow_visible.html b/test_fixtures/block/block_inflow_overflow_visible.html new file mode 100644 index 000000000..6cfc22d80 --- /dev/null +++ b/test_fixtures/block/block_inflow_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/content_size_with_border.html b/test_fixtures/flex/content_size_with_border.html new file mode 100644 index 000000000..facb374fe --- /dev/null +++ b/test_fixtures/flex/content_size_with_border.html @@ -0,0 +1,36 @@ + + + + + + + Test description + + + + +
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
XXXXXXXXXXXXXXXXXXXX
+
+ + + diff --git a/test_fixtures/flex/flex_absolute_overflow_clip.html b/test_fixtures/flex/flex_absolute_overflow_clip.html new file mode 100644 index 000000000..0f5873bfd --- /dev/null +++ b/test_fixtures/flex/flex_absolute_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_absolute_overflow_hidden.html b/test_fixtures/flex/flex_absolute_overflow_hidden.html new file mode 100644 index 000000000..0b2bf812c --- /dev/null +++ b/test_fixtures/flex/flex_absolute_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_absolute_overflow_scroll.html b/test_fixtures/flex/flex_absolute_overflow_scroll.html new file mode 100644 index 000000000..1f86b5f48 --- /dev/null +++ b/test_fixtures/flex/flex_absolute_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_absolute_overflow_visible.html b/test_fixtures/flex/flex_absolute_overflow_visible.html new file mode 100644 index 000000000..8540a85ae --- /dev/null +++ b/test_fixtures/flex/flex_absolute_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_inflow_overflow_clip.html b/test_fixtures/flex/flex_inflow_overflow_clip.html new file mode 100644 index 000000000..b9956cc1f --- /dev/null +++ b/test_fixtures/flex/flex_inflow_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_inflow_overflow_hidden.html b/test_fixtures/flex/flex_inflow_overflow_hidden.html new file mode 100644 index 000000000..bf73bd8f7 --- /dev/null +++ b/test_fixtures/flex/flex_inflow_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_inflow_overflow_scroll.html b/test_fixtures/flex/flex_inflow_overflow_scroll.html new file mode 100644 index 000000000..1a3357266 --- /dev/null +++ b/test_fixtures/flex/flex_inflow_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/flex/flex_inflow_overflow_visible.html b/test_fixtures/flex/flex_inflow_overflow_visible.html new file mode 100644 index 000000000..cf439a19d --- /dev/null +++ b/test_fixtures/flex/flex_inflow_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_absolute_overflow_clip.html b/test_fixtures/grid/grid_absolute_overflow_clip.html new file mode 100644 index 000000000..a9146984b --- /dev/null +++ b/test_fixtures/grid/grid_absolute_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_absolute_overflow_hidden.html b/test_fixtures/grid/grid_absolute_overflow_hidden.html new file mode 100644 index 000000000..e89a84975 --- /dev/null +++ b/test_fixtures/grid/grid_absolute_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_absolute_overflow_scroll.html b/test_fixtures/grid/grid_absolute_overflow_scroll.html new file mode 100644 index 000000000..a0e86a8f5 --- /dev/null +++ b/test_fixtures/grid/grid_absolute_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_absolute_overflow_visible.html b/test_fixtures/grid/grid_absolute_overflow_visible.html new file mode 100644 index 000000000..ed14fe283 --- /dev/null +++ b/test_fixtures/grid/grid_absolute_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_inflow_overflow_clip.html b/test_fixtures/grid/grid_inflow_overflow_clip.html new file mode 100644 index 000000000..6964d3b10 --- /dev/null +++ b/test_fixtures/grid/grid_inflow_overflow_clip.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_inflow_overflow_hidden.html b/test_fixtures/grid/grid_inflow_overflow_hidden.html new file mode 100644 index 000000000..dadf56e27 --- /dev/null +++ b/test_fixtures/grid/grid_inflow_overflow_hidden.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_inflow_overflow_scroll.html b/test_fixtures/grid/grid_inflow_overflow_scroll.html new file mode 100644 index 000000000..7f9a50f63 --- /dev/null +++ b/test_fixtures/grid/grid_inflow_overflow_scroll.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/grid/grid_inflow_overflow_visible.html b/test_fixtures/grid/grid_inflow_overflow_visible.html new file mode 100644 index 000000000..a05eb64ce --- /dev/null +++ b/test_fixtures/grid/grid_inflow_overflow_visible.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_clip.html b/test_fixtures/leaf/leaf_overflow_clip.html new file mode 100644 index 000000000..af49931d0 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_clip.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_clip_with_border.html b/test_fixtures/leaf/leaf_overflow_clip_with_border.html new file mode 100644 index 000000000..6fff879e5 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_clip_with_border.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_clip_with_border_and_padding.html b/test_fixtures/leaf/leaf_overflow_clip_with_border_and_padding.html new file mode 100644 index 000000000..910a67162 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_clip_with_border_and_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_clip_with_padding.html b/test_fixtures/leaf/leaf_overflow_clip_with_padding.html new file mode 100644 index 000000000..444cbe1a7 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_clip_with_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_hidden.html b/test_fixtures/leaf/leaf_overflow_hidden.html new file mode 100644 index 000000000..5d5ae342d --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_hidden.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_hidden_with_border.html b/test_fixtures/leaf/leaf_overflow_hidden_with_border.html new file mode 100644 index 000000000..e228968f6 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_hidden_with_border.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_hidden_with_border_and_padding.html b/test_fixtures/leaf/leaf_overflow_hidden_with_border_and_padding.html new file mode 100644 index 000000000..ec4be8c3b --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_hidden_with_border_and_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_hidden_with_padding.html b/test_fixtures/leaf/leaf_overflow_hidden_with_padding.html new file mode 100644 index 000000000..7bb26437a --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_hidden_with_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_scroll.html b/test_fixtures/leaf/leaf_overflow_scroll.html new file mode 100644 index 000000000..8af1a3449 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_scroll.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_scroll_with_border.html b/test_fixtures/leaf/leaf_overflow_scroll_with_border.html new file mode 100644 index 000000000..149e441b9 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_scroll_with_border.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_scroll_with_border_and_padding.html b/test_fixtures/leaf/leaf_overflow_scroll_with_border_and_padding.html new file mode 100644 index 000000000..d205bfbdf --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_scroll_with_border_and_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_scroll_with_padding.html b/test_fixtures/leaf/leaf_overflow_scroll_with_padding.html new file mode 100644 index 000000000..c8c77a9e2 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_scroll_with_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_visible.html b/test_fixtures/leaf/leaf_overflow_visible.html new file mode 100644 index 000000000..0fb8b0cfa --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_visible.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_visible_with_border.html b/test_fixtures/leaf/leaf_overflow_visible_with_border.html new file mode 100644 index 000000000..ff01c06e2 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_visible_with_border.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_visible_with_border_and_padding.html b/test_fixtures/leaf/leaf_overflow_visible_with_border_and_padding.html new file mode 100644 index 000000000..f83198c5a --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_visible_with_border_and_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/test_fixtures/leaf/leaf_overflow_visible_with_padding.html b/test_fixtures/leaf/leaf_overflow_visible_with_padding.html new file mode 100644 index 000000000..fac4176b0 --- /dev/null +++ b/test_fixtures/leaf/leaf_overflow_visible_with_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+ HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH​HHHHHHHHHHHHHHHHHHHHH +
+ + + diff --git a/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs index 4144b4bc2..fb5d58f34 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__bord let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -21,6 +22,10 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__bord .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__bord println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__cont .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -73,6 +153,10 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__cont taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__cont println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs index b8d123706..80e128378 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn block_absolute_aspect_ratio_fill_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn block_absolute_aspect_ratio_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_absolute_aspect_ratio_fill_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn block_absolute_aspect_ratio_fill_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn block_absolute_aspect_ratio_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs index 6e24b53ad..ffac2d38b 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -21,6 +22,10 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -73,6 +153,10 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn block_absolute_aspect_ratio_fill_height_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs index 8c615578c..d4301a4a8 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs @@ -4,24 +4,31 @@ fn block_absolute_aspect_ratio_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +42,86 @@ fn block_absolute_aspect_ratio_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 73f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 73f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,19 +130,22 @@ fn block_absolute_aspect_ratio_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy @@ -75,6 +153,10 @@ fn block_absolute_aspect_ratio_fill_max_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +170,84 @@ fn block_absolute_aspect_ratio_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 73f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 73f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs index 99a803fe5..f6ab51e43 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs @@ -4,24 +4,31 @@ fn block_absolute_aspect_ratio_fill_max_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +42,86 @@ fn block_absolute_aspect_ratio_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,19 +130,22 @@ fn block_absolute_aspect_ratio_fill_max_width__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy @@ -75,6 +153,10 @@ fn block_absolute_aspect_ratio_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +170,84 @@ fn block_absolute_aspect_ratio_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs index 4ef216a5c..3d9bcda30 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_min_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() @@ -16,6 +17,10 @@ fn block_absolute_aspect_ratio_fill_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn block_absolute_aspect_ratio_fill_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_absolute_aspect_ratio_fill_min_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() @@ -63,6 +137,10 @@ fn block_absolute_aspect_ratio_fill_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn block_absolute_aspect_ratio_fill_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs index d4b0e0d5f..fc7a6996e 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_min_width__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() @@ -16,6 +17,10 @@ fn block_absolute_aspect_ratio_fill_min_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn block_absolute_aspect_ratio_fill_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_absolute_aspect_ratio_fill_min_width__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() @@ -63,6 +137,10 @@ fn block_absolute_aspect_ratio_fill_min_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn block_absolute_aspect_ratio_fill_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs index 697c6fc3e..83b0aa3ef 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_width__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn block_absolute_aspect_ratio_fill_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn block_absolute_aspect_ratio_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_absolute_aspect_ratio_fill_width__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn block_absolute_aspect_ratio_fill_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn block_absolute_aspect_ratio_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs b/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs index 493ac0754..37d6ef180 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -63,6 +137,10 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn block_absolute_aspect_ratio_fill_width_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs b/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs index dc36bf32e..d0af5d7f9 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_height_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -17,6 +18,10 @@ fn block_absolute_aspect_ratio_height_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -30,18 +35,86 @@ fn block_absolute_aspect_ratio_height_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn block_absolute_aspect_ratio_height_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -65,6 +139,10 @@ fn block_absolute_aspect_ratio_height_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -78,16 +156,84 @@ fn block_absolute_aspect_ratio_height_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs b/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs index 028749dd3..a83a65372 100644 --- a/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs +++ b/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_aspect_ratio_width_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn block_absolute_aspect_ratio_width_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn block_absolute_aspect_ratio_width_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_absolute_aspect_ratio_width_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn block_absolute_aspect_ratio_width_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn block_absolute_aspect_ratio_width_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_child_with_margin_x.rs b/tests/generated/block/block_absolute_child_with_margin_x.rs index b9619a1c5..dd077549a 100644 --- a/tests/generated/block/block_absolute_child_with_margin_x.rs +++ b/tests/generated/block/block_absolute_child_with_margin_x.rs @@ -7,6 +7,7 @@ fn block_absolute_child_with_margin_x__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -18,6 +19,7 @@ fn block_absolute_child_with_margin_x__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -29,6 +31,7 @@ fn block_absolute_child_with_margin_x__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -41,6 +44,10 @@ fn block_absolute_child_with_margin_x__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -54,30 +61,164 @@ fn block_absolute_child_with_margin_x__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +231,7 @@ fn block_absolute_child_with_margin_x__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -102,6 +244,7 @@ fn block_absolute_child_with_margin_x__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -114,6 +257,7 @@ fn block_absolute_child_with_margin_x__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -127,6 +271,10 @@ fn block_absolute_child_with_margin_x__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -140,28 +288,162 @@ fn block_absolute_child_with_margin_x__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_child_with_margin_y.rs b/tests/generated/block/block_absolute_child_with_margin_y.rs index 88509116c..6ab376ae0 100644 --- a/tests/generated/block/block_absolute_child_with_margin_y.rs +++ b/tests/generated/block/block_absolute_child_with_margin_y.rs @@ -7,6 +7,7 @@ fn block_absolute_child_with_margin_y__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -18,6 +19,7 @@ fn block_absolute_child_with_margin_y__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -29,6 +31,7 @@ fn block_absolute_child_with_margin_y__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -41,6 +44,10 @@ fn block_absolute_child_with_margin_y__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -54,30 +61,164 @@ fn block_absolute_child_with_margin_y__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node0, 7f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +231,7 @@ fn block_absolute_child_with_margin_y__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -102,6 +244,7 @@ fn block_absolute_child_with_margin_y__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -114,6 +257,7 @@ fn block_absolute_child_with_margin_y__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -127,6 +271,10 @@ fn block_absolute_child_with_margin_y__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -140,28 +288,162 @@ fn block_absolute_child_with_margin_y__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node0, 7f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_child_with_max_height.rs b/tests/generated/block/block_absolute_child_with_max_height.rs index 0b8ce9a1e..079d925c0 100644 --- a/tests/generated/block/block_absolute_child_with_max_height.rs +++ b/tests/generated/block/block_absolute_child_with_max_height.rs @@ -7,6 +7,7 @@ fn block_absolute_child_with_max_height__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(150f32), @@ -19,6 +20,10 @@ fn block_absolute_child_with_max_height__border_box() { taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -30,6 +35,10 @@ fn block_absolute_child_with_max_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -43,24 +52,137 @@ fn block_absolute_child_with_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 30f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +195,7 @@ fn block_absolute_child_with_max_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(150f32), @@ -86,6 +209,10 @@ fn block_absolute_child_with_max_height__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -98,6 +225,10 @@ fn block_absolute_child_with_max_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -111,22 +242,135 @@ fn block_absolute_child_with_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 30f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_child_order.rs b/tests/generated/block/block_absolute_layout_child_order.rs index 52bf4d69b..bff71cbe2 100644 --- a/tests/generated/block/block_absolute_layout_child_order.rs +++ b/tests/generated/block/block_absolute_layout_child_order.rs @@ -7,6 +7,7 @@ fn block_absolute_layout_child_order__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -18,6 +19,7 @@ fn block_absolute_layout_child_order__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -28,6 +30,7 @@ fn block_absolute_layout_child_order__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -39,6 +42,10 @@ fn block_absolute_layout_child_order__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -54,30 +61,164 @@ fn block_absolute_layout_child_order__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +231,7 @@ fn block_absolute_layout_child_order__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -102,6 +244,7 @@ fn block_absolute_layout_child_order__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -113,6 +256,7 @@ fn block_absolute_layout_child_order__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -125,6 +269,10 @@ fn block_absolute_layout_child_order__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -140,28 +288,162 @@ fn block_absolute_layout_child_order__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_no_size.rs b/tests/generated/block/block_absolute_layout_no_size.rs index de83fe11d..8abfeed21 100644 --- a/tests/generated/block/block_absolute_layout_no_size.rs +++ b/tests/generated/block/block_absolute_layout_no_size.rs @@ -5,12 +5,20 @@ fn block_absolute_layout_no_size__border_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }) + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -24,18 +32,86 @@ fn block_absolute_layout_no_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,6 +124,7 @@ fn block_absolute_layout_no_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -56,6 +133,10 @@ fn block_absolute_layout_no_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -69,16 +150,84 @@ fn block_absolute_layout_no_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs index 4327e2c05..4129a0b38 100644 --- a/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__border_box() .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -20,6 +21,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__border_box() .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -32,6 +34,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__border_box() .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.1f32), bottom: percent(0.1f32) }, ..Default::default() @@ -41,6 +44,10 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -54,30 +61,170 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +238,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__content_box() display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -104,6 +252,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__content_box() display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -117,6 +266,7 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__content_box() display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.1f32), bottom: percent(0.1f32) }, ..Default::default() @@ -127,6 +277,10 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -140,28 +294,168 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height__content_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_percentage_height.rs b/tests/generated/block/block_absolute_layout_percentage_height.rs index 344041033..811910557 100644 --- a/tests/generated/block/block_absolute_layout_percentage_height.rs +++ b/tests/generated/block/block_absolute_layout_percentage_height.rs @@ -7,6 +7,7 @@ fn block_absolute_layout_percentage_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -19,6 +20,10 @@ fn block_absolute_layout_percentage_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn block_absolute_layout_percentage_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn block_absolute_layout_percentage_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -69,6 +143,10 @@ fn block_absolute_layout_percentage_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn block_absolute_layout_percentage_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs b/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs index 82162395a..5a9354879 100644 --- a/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs +++ b/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs @@ -7,6 +7,7 @@ fn block_absolute_layout_row_width_height_end_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -19,6 +20,10 @@ fn block_absolute_layout_row_width_height_end_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn block_absolute_layout_row_width_height_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn block_absolute_layout_row_width_height_end_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -69,6 +143,10 @@ fn block_absolute_layout_row_width_height_end_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn block_absolute_layout_row_width_height_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs b/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs index c106af61d..7ac37cb01 100644 --- a/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs +++ b/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_start_top_end_bottom__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -21,6 +22,10 @@ fn block_absolute_layout_start_top_end_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -34,18 +39,86 @@ fn block_absolute_layout_start_top_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_absolute_layout_start_top_end_bottom__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -73,6 +147,10 @@ fn block_absolute_layout_start_top_end_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,16 +164,84 @@ fn block_absolute_layout_start_top_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs b/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs index 0609cefb2..b220ff183 100644 --- a/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs +++ b/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_width_height_end_bottom__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -20,6 +21,10 @@ fn block_absolute_layout_width_height_end_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn block_absolute_layout_width_height_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +131,7 @@ fn block_absolute_layout_width_height_end_bottom__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +145,10 @@ fn block_absolute_layout_width_height_end_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn block_absolute_layout_width_height_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_width_height_start_top.rs b/tests/generated/block/block_absolute_layout_width_height_start_top.rs index 692ae20af..dd13fe231 100644 --- a/tests/generated/block/block_absolute_layout_width_height_start_top.rs +++ b/tests/generated/block/block_absolute_layout_width_height_start_top.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_width_height_start_top__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -20,6 +21,10 @@ fn block_absolute_layout_width_height_start_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn block_absolute_layout_width_height_start_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +131,7 @@ fn block_absolute_layout_width_height_start_top__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +145,10 @@ fn block_absolute_layout_width_height_start_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn block_absolute_layout_width_height_start_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs index 6ac862338..e90d17142 100644 --- a/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs +++ b/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_width_height_start_top_end_bottom__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -25,6 +26,10 @@ fn block_absolute_layout_width_height_start_top_end_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -38,18 +43,86 @@ fn block_absolute_layout_width_height_start_top_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn block_absolute_layout_width_height_start_top_end_bottom__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -81,6 +155,10 @@ fn block_absolute_layout_width_height_start_top_end_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -94,16 +172,84 @@ fn block_absolute_layout_width_height_start_top_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_layout_within_border.rs b/tests/generated/block/block_absolute_layout_within_border.rs index 070216685..da69b4274 100644 --- a/tests/generated/block/block_absolute_layout_within_border.rs +++ b/tests/generated/block/block_absolute_layout_within_border.rs @@ -8,6 +8,7 @@ fn block_absolute_layout_within_border__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -20,6 +21,7 @@ fn block_absolute_layout_within_border__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,7 @@ fn block_absolute_layout_within_border__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -50,6 +53,7 @@ fn block_absolute_layout_within_border__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -68,6 +72,10 @@ fn block_absolute_layout_within_border__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -93,36 +101,203 @@ fn block_absolute_layout_within_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -136,6 +311,7 @@ fn block_absolute_layout_within_border__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -149,6 +325,7 @@ fn block_absolute_layout_within_border__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -162,6 +339,7 @@ fn block_absolute_layout_within_border__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -181,6 +359,7 @@ fn block_absolute_layout_within_border__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -200,6 +379,10 @@ fn block_absolute_layout_within_border__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -225,34 +408,201 @@ fn block_absolute_layout_within_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node3, 70f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs index d1230cbf9..4484b355d 100644 --- a/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs index a6cefdd9a..6c3f83d34 100644 --- a/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs index d8d223a9c..ab175308d 100644 --- a/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_bottom_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_bottom_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -39,18 +44,86 @@ fn block_absolute_margin_auto_bottom_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn block_absolute_margin_auto_bottom_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -82,6 +156,10 @@ fn block_absolute_margin_auto_bottom_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -96,16 +174,84 @@ fn block_absolute_margin_auto_bottom_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs index d79391b06..f93ac8878 100644 --- a/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_bottom_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_bottom_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_bottom_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_bottom_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -80,6 +154,10 @@ fn block_absolute_margin_auto_bottom_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_bottom_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs index 84aa8a734..dd85661e4 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_and_right_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_left_and_right_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_left_and_right_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_left_and_right_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_left_and_right_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_left_and_right_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs index 210affa03..0e4919e1b 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_and_right_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_left_and_right_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_left_and_right_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_left_and_right_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_left_and_right_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_left_and_right_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs index bcc34af4a..cb0eb206c 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__border_b let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__border_b .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__border_b println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, -40f32, "x of node {:?}. Expected {}. Actual {}", node0, -40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__content_ .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__content_ taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset__content_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, -40f32, "x of node {:?}. Expected {}. Actual {}", node0, -40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs index 4b3c98090..0396c0076 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__borde let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__borde .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__borde println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__conte .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__conte taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset__conte println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs index 7759ef4e0..b5c10ba8f 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, -50f32, "x of node {:?}. Expected {}. Actual {}", node0, -50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, -50f32, "x of node {:?}. Expected {}. Actual {}", node0, -50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs index 175ceb08d..dcf600bed 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs index 83c1c7eb2..ad4b97bac 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__bo let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__bo .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__bo println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 30f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__co .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__co taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset__co println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 30f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs index a6592fd0b..452212de2 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs index 28fd469ae..d4b7c1c3c 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_left_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_left_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node0, 130f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_left_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -81,6 +155,10 @@ fn block_absolute_margin_auto_left_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_left_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node0, 130f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs index f0a6d304e..c9007cc65 100644 --- a/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_left_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_left_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -37,18 +42,86 @@ fn block_absolute_margin_auto_left_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +134,7 @@ fn block_absolute_margin_auto_left_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +153,10 @@ fn block_absolute_margin_auto_left_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -92,16 +170,84 @@ fn block_absolute_margin_auto_left_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs index 6db20c4c3..5e77230ac 100644 --- a/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_multiple_children_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,7 @@ fn block_absolute_margin_auto_multiple_children_with_inset__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -42,6 +44,10 @@ fn block_absolute_margin_auto_multiple_children_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -56,24 +62,125 @@ fn block_absolute_margin_auto_multiple_children_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +193,7 @@ fn block_absolute_margin_auto_multiple_children_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,6 +212,7 @@ fn block_absolute_margin_auto_multiple_children_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -123,6 +232,10 @@ fn block_absolute_margin_auto_multiple_children_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -137,22 +250,123 @@ fn block_absolute_margin_auto_multiple_children_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs index a5357fe86..bf311f77b 100644 --- a/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_multiple_children_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -23,6 +24,7 @@ fn block_absolute_margin_auto_multiple_children_without_inset__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -40,6 +42,10 @@ fn block_absolute_margin_auto_multiple_children_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -54,24 +60,125 @@ fn block_absolute_margin_auto_multiple_children_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -84,6 +191,7 @@ fn block_absolute_margin_auto_multiple_children_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +209,7 @@ fn block_absolute_margin_auto_multiple_children_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -119,6 +228,10 @@ fn block_absolute_margin_auto_multiple_children_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -133,22 +246,123 @@ fn block_absolute_margin_auto_multiple_children_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs index 9308f23dd..aa33f970d 100644 --- a/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_right_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_right_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -39,18 +44,86 @@ fn block_absolute_margin_auto_right_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn block_absolute_margin_auto_right_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -82,6 +156,10 @@ fn block_absolute_margin_auto_right_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -96,16 +174,84 @@ fn block_absolute_margin_auto_right_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs index 32ffd4812..3961ba365 100644 --- a/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_right_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_right_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_right_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_right_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -80,6 +154,10 @@ fn block_absolute_margin_auto_right_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_right_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs b/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs index c48285d2a..2e3660866 100644 --- a/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_top_with_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn block_absolute_margin_auto_top_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -39,18 +44,86 @@ fn block_absolute_margin_auto_top_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node0, 140f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn block_absolute_margin_auto_top_with_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -82,6 +156,10 @@ fn block_absolute_margin_auto_top_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -96,16 +174,84 @@ fn block_absolute_margin_auto_top_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node0, 140f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs b/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs index 712c56a69..933ef2290 100644 --- a/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs @@ -7,6 +7,7 @@ fn block_absolute_margin_auto_top_without_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +25,10 @@ fn block_absolute_margin_auto_top_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -38,18 +43,86 @@ fn block_absolute_margin_auto_top_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_margin_auto_top_without_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -80,6 +154,10 @@ fn block_absolute_margin_auto_top_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -94,16 +172,84 @@ fn block_absolute_margin_auto_top_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs b/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs index 6444efa4a..3cf283a31 100644 --- a/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs +++ b/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs @@ -8,6 +8,7 @@ fn block_absolute_margin_bottom_left_with_inset__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +27,10 @@ fn block_absolute_margin_bottom_left_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -39,18 +44,86 @@ fn block_absolute_margin_bottom_left_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +137,7 @@ fn block_absolute_margin_bottom_left_with_inset__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -83,6 +157,10 @@ fn block_absolute_margin_bottom_left_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -96,16 +174,84 @@ fn block_absolute_margin_bottom_left_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs b/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs index cc40a4e19..3f70e8f08 100644 --- a/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs +++ b/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs @@ -8,6 +8,7 @@ fn block_absolute_margin_bottom_left_without_inset__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -20,6 +21,10 @@ fn block_absolute_margin_bottom_left_without_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn block_absolute_margin_bottom_left_without_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +131,7 @@ fn block_absolute_margin_bottom_left_without_inset__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +145,10 @@ fn block_absolute_margin_bottom_left_without_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn block_absolute_margin_bottom_left_without_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_minmax_bottom_right_max.rs b/tests/generated/block/block_absolute_minmax_bottom_right_max.rs index 99dab5704..941e9e8f1 100644 --- a/tests/generated/block/block_absolute_minmax_bottom_right_max.rs +++ b/tests/generated/block/block_absolute_minmax_bottom_right_max.rs @@ -8,6 +8,7 @@ fn block_absolute_minmax_bottom_right_max__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -24,6 +25,10 @@ fn block_absolute_minmax_bottom_right_max__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,18 +42,86 @@ fn block_absolute_minmax_bottom_right_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_minmax_bottom_right_max__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -79,6 +153,10 @@ fn block_absolute_minmax_bottom_right_max__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -92,16 +170,84 @@ fn block_absolute_minmax_bottom_right_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs b/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs index df8830ae4..6900321df 100644 --- a/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs +++ b/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs @@ -8,6 +8,7 @@ fn block_absolute_minmax_bottom_right_min_max__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -24,6 +25,10 @@ fn block_absolute_minmax_bottom_right_min_max__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,18 +42,86 @@ fn block_absolute_minmax_bottom_right_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn block_absolute_minmax_bottom_right_min_max__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -79,6 +153,10 @@ fn block_absolute_minmax_bottom_right_min_max__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -92,16 +170,84 @@ fn block_absolute_minmax_bottom_right_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs b/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs index 1ccef69e4..05dd92afd 100644 --- a/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs +++ b/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs @@ -8,6 +8,7 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -28,6 +29,10 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -41,18 +46,86 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +139,7 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -87,6 +161,10 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -100,16 +178,84 @@ fn block_absolute_minmax_bottom_right_min_max_preferred__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs b/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs index 1bb770baa..80d85e788 100644 --- a/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs +++ b/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs @@ -8,6 +8,7 @@ fn block_absolute_minmax_top_left_bottom_right_max__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(30f32), @@ -25,6 +26,10 @@ fn block_absolute_minmax_top_left_bottom_right_max__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -38,18 +43,86 @@ fn block_absolute_minmax_top_left_bottom_right_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn block_absolute_minmax_top_left_bottom_right_max__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(30f32), @@ -81,6 +155,10 @@ fn block_absolute_minmax_top_left_bottom_right_max__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -94,16 +172,84 @@ fn block_absolute_minmax_top_left_bottom_right_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs b/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs index bf2653706..cefd53511 100644 --- a/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs +++ b/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs @@ -8,6 +8,7 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -29,6 +30,10 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -42,18 +47,86 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +140,7 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -89,6 +163,10 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -102,16 +180,84 @@ fn block_absolute_minmax_top_left_bottom_right_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_no_styles.rs b/tests/generated/block/block_absolute_no_styles.rs index da0e708c0..4a1de3a94 100644 --- a/tests/generated/block/block_absolute_no_styles.rs +++ b/tests/generated/block/block_absolute_no_styles.rs @@ -7,6 +7,7 @@ fn block_absolute_no_styles__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -18,12 +19,20 @@ fn block_absolute_no_styles__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -31,24 +40,125 @@ fn block_absolute_no_styles__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +171,7 @@ fn block_absolute_no_styles__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -73,6 +184,7 @@ fn block_absolute_no_styles__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -81,6 +193,10 @@ fn block_absolute_no_styles__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -90,22 +206,123 @@ fn block_absolute_no_styles__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_overflow_clip.rs b/tests/generated/block/block_absolute_overflow_clip.rs new file mode 100644 index 000000000..1436acc7e --- /dev/null +++ b/tests/generated/block/block_absolute_overflow_clip.rs @@ -0,0 +1,295 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_absolute_overflow_hidden.rs b/tests/generated/block/block_absolute_overflow_hidden.rs new file mode 100644 index 000000000..93214122c --- /dev/null +++ b/tests/generated/block/block_absolute_overflow_hidden.rs @@ -0,0 +1,303 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_absolute_overflow_scroll.rs b/tests/generated/block/block_absolute_overflow_scroll.rs new file mode 100644 index 000000000..4e7d4adb9 --- /dev/null +++ b/tests/generated/block/block_absolute_overflow_scroll.rs @@ -0,0 +1,303 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 66f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 66f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 43f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 43f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 52f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 52f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_absolute_overflow_visible.rs b/tests/generated/block/block_absolute_overflow_visible.rs new file mode 100644 index 000000000..29d03f6df --- /dev/null +++ b/tests/generated/block/block_absolute_overflow_visible.rs @@ -0,0 +1,301 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs b/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs index 60394dbcd..28a52b129 100644 --- a/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs +++ b/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs @@ -8,6 +8,7 @@ fn block_absolute_padding_border_overrides_max_size__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -29,7 +30,14 @@ fn block_absolute_padding_border_overrides_max_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -37,18 +45,86 @@ fn block_absolute_padding_border_overrides_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +138,7 @@ fn block_absolute_padding_border_overrides_max_size__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -86,6 +163,10 @@ fn block_absolute_padding_border_overrides_max_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -95,16 +176,84 @@ fn block_absolute_padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_padding_border_overrides_size.rs b/tests/generated/block/block_absolute_padding_border_overrides_size.rs index 01ecc6e73..3975f6ee8 100644 --- a/tests/generated/block/block_absolute_padding_border_overrides_size.rs +++ b/tests/generated/block/block_absolute_padding_border_overrides_size.rs @@ -8,6 +8,7 @@ fn block_absolute_padding_border_overrides_size__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -29,7 +30,14 @@ fn block_absolute_padding_border_overrides_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -37,18 +45,86 @@ fn block_absolute_padding_border_overrides_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +138,7 @@ fn block_absolute_padding_border_overrides_size__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -86,6 +163,10 @@ fn block_absolute_padding_border_overrides_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -95,16 +176,84 @@ fn block_absolute_padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 34f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 34f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 26f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_absolute_resolved_insets.rs b/tests/generated/block/block_absolute_resolved_insets.rs index 82bf48514..409c3a75a 100644 --- a/tests/generated/block/block_absolute_resolved_insets.rs +++ b/tests/generated/block/block_absolute_resolved_insets.rs @@ -7,6 +7,7 @@ fn block_absolute_resolved_insets__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -19,6 +20,7 @@ fn block_absolute_resolved_insets__border_box() { let node01 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -26,6 +28,7 @@ fn block_absolute_resolved_insets__border_box() { let node02 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -33,6 +36,7 @@ fn block_absolute_resolved_insets__border_box() { let node03 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -40,6 +44,7 @@ fn block_absolute_resolved_insets__border_box() { let node04 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -47,6 +52,7 @@ fn block_absolute_resolved_insets__border_box() { let node05 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -59,6 +65,10 @@ fn block_absolute_resolved_insets__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -83,6 +93,7 @@ fn block_absolute_resolved_insets__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -95,6 +106,7 @@ fn block_absolute_resolved_insets__border_box() { let node11 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -102,6 +114,7 @@ fn block_absolute_resolved_insets__border_box() { let node12 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -109,6 +122,7 @@ fn block_absolute_resolved_insets__border_box() { let node13 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -116,6 +130,7 @@ fn block_absolute_resolved_insets__border_box() { let node14 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -123,6 +138,7 @@ fn block_absolute_resolved_insets__border_box() { let node15 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -164,6 +180,7 @@ fn block_absolute_resolved_insets__border_box() { let node20 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -174,6 +191,7 @@ fn block_absolute_resolved_insets__border_box() { let node21 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -187,6 +205,10 @@ fn block_absolute_resolved_insets__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -208,137 +230,762 @@ fn block_absolute_resolved_insets__border_box() { &[node20, node21], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1, node2]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node00, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node00, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node02, 180f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node02, 180f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node05, 160f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node05, 160f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node10, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node10, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 165f32, "x of node {:?}. Expected {}. Actual {}", node12, 165f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node12, 165f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 165f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node15, 145f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node15, 145f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node2, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node2, 200f32, size.height); - assert_eq!(location.x, 400f32, "x of node {:?}. Expected {}. Actual {}", node2, 400f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 400f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node20, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node20, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node21, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node21, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node21, 35f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node21, 45f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -351,6 +998,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -364,6 +1012,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -372,6 +1021,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -380,6 +1030,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -388,6 +1039,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -396,6 +1048,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -409,6 +1062,10 @@ fn block_absolute_resolved_insets__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -434,6 +1091,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -447,6 +1105,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -455,6 +1114,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -463,6 +1123,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -471,6 +1132,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -479,6 +1141,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -522,6 +1185,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -533,6 +1197,7 @@ fn block_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -547,6 +1212,10 @@ fn block_absolute_resolved_insets__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -570,7 +1239,14 @@ fn block_absolute_resolved_insets__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1, node2], ) .unwrap(); @@ -578,130 +1254,744 @@ fn block_absolute_resolved_insets__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 810f32, "width of node {:?}. Expected {}. Actual {}", node, 810f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 810f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 810f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 270f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node0, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node0, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node00, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node00, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node02, 250f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node02, 250f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 230f32, "width of node {:?}. Expected {}. Actual {}", node05, 230f32, size.width); - assert_eq!(size.height, 230f32, "height of node {:?}. Expected {}. Actual {}", node05, 230f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 230f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 230f32, layout.size.width); + } + if layout.size.height != 230f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 230f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node1, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node1, 270f32, size.height); - assert_eq!(location.x, 270f32, "x of node {:?}. Expected {}. Actual {}", node1, 270f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 270f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node10, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node10, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 235f32, "x of node {:?}. Expected {}. Actual {}", node12, 235f32, location.x); - assert_eq!(location.y, 235f32, "y of node {:?}. Expected {}. Actual {}", node12, 235f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 235f32, layout.location.x); + } + if layout.location.y != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 235f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 215f32, "width of node {:?}. Expected {}. Actual {}", node15, 215f32, size.width); - assert_eq!(size.height, 215f32, "height of node {:?}. Expected {}. Actual {}", node15, 215f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 215f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 215f32, layout.size.width); + } + if layout.size.height != 215f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 215f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node2, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node2, 270f32, size.height); - assert_eq!(location.x, 540f32, "x of node {:?}. Expected {}. Actual {}", node2, 540f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 540f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 540f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node20, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node20, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node21, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node21, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node21, 35f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node21, 45f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child.rs b/tests/generated/block/block_align_baseline_child.rs index 1e593e786..3ca296976 100644 --- a/tests/generated/block/block_align_baseline_child.rs +++ b/tests/generated/block/block_align_baseline_child.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -16,6 +17,7 @@ fn block_align_baseline_child__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,6 +29,10 @@ fn block_align_baseline_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -39,6 +45,10 @@ fn block_align_baseline_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -53,30 +63,170 @@ fn block_align_baseline_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +239,7 @@ fn block_align_baseline_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -99,6 +250,7 @@ fn block_align_baseline_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -111,6 +263,10 @@ fn block_align_baseline_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -124,6 +280,10 @@ fn block_align_baseline_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -138,28 +298,168 @@ fn block_align_baseline_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child_margin.rs b/tests/generated/block/block_align_baseline_child_margin.rs index c3af16fb6..6fd33639f 100644 --- a/tests/generated/block/block_align_baseline_child_margin.rs +++ b/tests/generated/block/block_align_baseline_child_margin.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -22,6 +23,7 @@ fn block_align_baseline_child_margin__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -39,6 +41,10 @@ fn block_align_baseline_child_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +57,10 @@ fn block_align_baseline_child_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -65,30 +75,170 @@ fn block_align_baseline_child_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +251,7 @@ fn block_align_baseline_child_margin__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -117,6 +268,7 @@ fn block_align_baseline_child_margin__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -135,6 +287,10 @@ fn block_align_baseline_child_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -148,6 +304,10 @@ fn block_align_baseline_child_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -162,28 +322,168 @@ fn block_align_baseline_child_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child_margin_percent.rs b/tests/generated/block/block_align_baseline_child_margin_percent.rs index e10373411..1d62bd4bc 100644 --- a/tests/generated/block/block_align_baseline_child_margin_percent.rs +++ b/tests/generated/block/block_align_baseline_child_margin_percent.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child_margin_percent__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -23,6 +24,7 @@ fn block_align_baseline_child_margin_percent__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -40,6 +42,10 @@ fn block_align_baseline_child_margin_percent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -52,6 +58,10 @@ fn block_align_baseline_child_margin_percent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -66,30 +76,170 @@ fn block_align_baseline_child_margin_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +252,7 @@ fn block_align_baseline_child_margin_percent__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -119,6 +270,7 @@ fn block_align_baseline_child_margin_percent__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -137,6 +289,10 @@ fn block_align_baseline_child_margin_percent__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +306,10 @@ fn block_align_baseline_child_margin_percent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -164,28 +324,168 @@ fn block_align_baseline_child_margin_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child_padding.rs b/tests/generated/block/block_align_baseline_child_padding.rs index 848916cca..f252681af 100644 --- a/tests/generated/block/block_align_baseline_child_padding.rs +++ b/tests/generated/block/block_align_baseline_child_padding.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child_padding__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn block_align_baseline_child_padding__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn block_align_baseline_child_padding__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -46,6 +52,10 @@ fn block_align_baseline_child_padding__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -66,30 +76,170 @@ fn block_align_baseline_child_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +252,7 @@ fn block_align_baseline_child_padding__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -113,6 +264,7 @@ fn block_align_baseline_child_padding__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -125,6 +277,10 @@ fn block_align_baseline_child_padding__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -144,6 +300,10 @@ fn block_align_baseline_child_padding__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -164,28 +324,168 @@ fn block_align_baseline_child_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 110f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node1, 25f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child_top.rs b/tests/generated/block/block_align_baseline_child_top.rs index 042ea3541..dcbad2da2 100644 --- a/tests/generated/block/block_align_baseline_child_top.rs +++ b/tests/generated/block/block_align_baseline_child_top.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child_top__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,7 @@ fn block_align_baseline_child_top__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -29,6 +31,10 @@ fn block_align_baseline_child_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -41,6 +47,10 @@ fn block_align_baseline_child_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -55,30 +65,170 @@ fn block_align_baseline_child_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +241,7 @@ fn block_align_baseline_child_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +254,7 @@ fn block_align_baseline_child_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -115,6 +267,10 @@ fn block_align_baseline_child_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -128,6 +284,10 @@ fn block_align_baseline_child_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -142,28 +302,168 @@ fn block_align_baseline_child_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_child_top2.rs b/tests/generated/block/block_align_baseline_child_top2.rs index a56d8f853..9ec84f318 100644 --- a/tests/generated/block/block_align_baseline_child_top2.rs +++ b/tests/generated/block/block_align_baseline_child_top2.rs @@ -7,6 +7,7 @@ fn block_align_baseline_child_top2__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn block_align_baseline_child_top2__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn block_align_baseline_child_top2__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -41,6 +47,10 @@ fn block_align_baseline_child_top2__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -55,30 +65,170 @@ fn block_align_baseline_child_top2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +241,7 @@ fn block_align_baseline_child_top2__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -102,6 +253,7 @@ fn block_align_baseline_child_top2__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -114,6 +266,10 @@ fn block_align_baseline_child_top2__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -128,6 +284,10 @@ fn block_align_baseline_child_top2__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -142,28 +302,168 @@ fn block_align_baseline_child_top2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_align_baseline_double_nested_child.rs b/tests/generated/block/block_align_baseline_double_nested_child.rs index 83f38648e..c7a7d5824 100644 --- a/tests/generated/block/block_align_baseline_double_nested_child.rs +++ b/tests/generated/block/block_align_baseline_double_nested_child.rs @@ -7,6 +7,7 @@ fn block_align_baseline_double_nested_child__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn block_align_baseline_double_nested_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -30,6 +35,7 @@ fn block_align_baseline_double_nested_child__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -41,6 +47,10 @@ fn block_align_baseline_double_nested_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -53,6 +63,10 @@ fn block_align_baseline_double_nested_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -67,36 +81,215 @@ fn block_align_baseline_double_nested_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -109,6 +302,7 @@ fn block_align_baseline_double_nested_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -121,6 +315,10 @@ fn block_align_baseline_double_nested_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -134,6 +332,7 @@ fn block_align_baseline_double_nested_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -146,6 +345,10 @@ fn block_align_baseline_double_nested_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -159,6 +362,10 @@ fn block_align_baseline_double_nested_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -173,34 +380,213 @@ fn block_align_baseline_double_nested_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_height.rs b/tests/generated/block/block_aspect_ratio_fill_height.rs index b42b4359b..8d5ad200c 100644 --- a/tests/generated/block/block_aspect_ratio_fill_height.rs +++ b/tests/generated/block/block_aspect_ratio_fill_height.rs @@ -7,6 +7,7 @@ fn block_aspect_ratio_fill_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn block_aspect_ratio_fill_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn block_aspect_ratio_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_aspect_ratio_fill_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn block_aspect_ratio_fill_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn block_aspect_ratio_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_max_height.rs b/tests/generated/block/block_aspect_ratio_fill_max_height.rs index 26624f97a..af269b5a6 100644 --- a/tests/generated/block/block_aspect_ratio_fill_max_height.rs +++ b/tests/generated/block/block_aspect_ratio_fill_max_height.rs @@ -4,11 +4,31 @@ fn block_aspect_ratio_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { display : taffy :: style :: Display :: Block , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -22,18 +42,86 @@ fn block_aspect_ratio_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,12 +130,33 @@ fn block_aspect_ratio_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { display : taffy :: style :: Display :: Block , box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -61,16 +170,84 @@ fn block_aspect_ratio_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_max_width.rs b/tests/generated/block/block_aspect_ratio_fill_max_width.rs index 4fa31aeb8..df3cc6f42 100644 --- a/tests/generated/block/block_aspect_ratio_fill_max_width.rs +++ b/tests/generated/block/block_aspect_ratio_fill_max_width.rs @@ -8,6 +8,10 @@ fn block_aspect_ratio_fill_max_width__border_box() { .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -19,6 +23,10 @@ fn block_aspect_ratio_fill_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +40,86 @@ fn block_aspect_ratio_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +133,10 @@ fn block_aspect_ratio_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -69,6 +149,10 @@ fn block_aspect_ratio_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,84 @@ fn block_aspect_ratio_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_min_height.rs b/tests/generated/block/block_aspect_ratio_fill_min_height.rs index c7180317f..3722f7f6e 100644 --- a/tests/generated/block/block_aspect_ratio_fill_min_height.rs +++ b/tests/generated/block/block_aspect_ratio_fill_min_height.rs @@ -7,6 +7,7 @@ fn block_aspect_ratio_fill_min_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn block_aspect_ratio_fill_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn block_aspect_ratio_fill_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_aspect_ratio_fill_min_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn block_aspect_ratio_fill_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn block_aspect_ratio_fill_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_min_width.rs b/tests/generated/block/block_aspect_ratio_fill_min_width.rs index 763ad72ff..3d4b72ec2 100644 --- a/tests/generated/block/block_aspect_ratio_fill_min_width.rs +++ b/tests/generated/block/block_aspect_ratio_fill_min_width.rs @@ -8,6 +8,10 @@ fn block_aspect_ratio_fill_min_width__border_box() { .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -19,6 +23,10 @@ fn block_aspect_ratio_fill_min_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +40,86 @@ fn block_aspect_ratio_fill_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +133,10 @@ fn block_aspect_ratio_fill_min_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -69,6 +149,10 @@ fn block_aspect_ratio_fill_min_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,84 @@ fn block_aspect_ratio_fill_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_aspect_ratio_fill_width.rs b/tests/generated/block/block_aspect_ratio_fill_width.rs index e6c3b6823..a02d97998 100644 --- a/tests/generated/block/block_aspect_ratio_fill_width.rs +++ b/tests/generated/block/block_aspect_ratio_fill_width.rs @@ -7,6 +7,7 @@ fn block_aspect_ratio_fill_width__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn block_aspect_ratio_fill_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn block_aspect_ratio_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn block_aspect_ratio_fill_width__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn block_aspect_ratio_fill_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn block_aspect_ratio_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_basic.rs b/tests/generated/block/block_basic.rs index 4cde7c64c..5498a9ce0 100644 --- a/tests/generated/block/block_basic.rs +++ b/tests/generated/block/block_basic.rs @@ -6,12 +6,14 @@ fn block_basic__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -20,6 +22,10 @@ fn block_basic__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -30,24 +36,125 @@ fn block_basic__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +166,7 @@ fn block_basic__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -66,6 +174,7 @@ fn block_basic__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -75,6 +184,10 @@ fn block_basic__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -85,22 +198,123 @@ fn block_basic__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_border_fixed_size.rs b/tests/generated/block/block_border_fixed_size.rs index bfd644606..d750865c9 100644 --- a/tests/generated/block/block_border_fixed_size.rs +++ b/tests/generated/block/block_border_fixed_size.rs @@ -6,12 +6,14 @@ fn block_border_fixed_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -20,6 +22,10 @@ fn block_border_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -39,24 +45,125 @@ fn block_border_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node0, 38f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 38f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node1, 38f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 38f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_border_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -75,6 +183,7 @@ fn block_border_fixed_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -84,6 +193,10 @@ fn block_border_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,22 +216,123 @@ fn block_border_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 58f32, "height of node {:?}. Expected {}. Actual {}", node, 58f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 58f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 58f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_border_intrinsic_size.rs b/tests/generated/block/block_border_intrinsic_size.rs index 5653f51ad..96a939754 100644 --- a/tests/generated/block/block_border_intrinsic_size.rs +++ b/tests/generated/block/block_border_intrinsic_size.rs @@ -6,6 +6,7 @@ fn block_border_intrinsic_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn block_border_intrinsic_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -23,6 +25,10 @@ fn block_border_intrinsic_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -38,24 +44,125 @@ fn block_border_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 28f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +174,7 @@ fn block_border_intrinsic_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -77,6 +185,7 @@ fn block_border_intrinsic_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -86,6 +195,10 @@ fn block_border_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -101,22 +214,123 @@ fn block_border_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 28f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_border_percentage_fixed_size.rs b/tests/generated/block/block_border_percentage_fixed_size.rs index a2f4809f9..395d98c6b 100644 --- a/tests/generated/block/block_border_percentage_fixed_size.rs +++ b/tests/generated/block/block_border_percentage_fixed_size.rs @@ -7,13 +7,21 @@ fn block_border_percentage_fixed_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -21,6 +29,10 @@ fn block_border_percentage_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,24 +46,131 @@ fn block_border_percentage_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +183,7 @@ fn block_border_percentage_fixed_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -73,6 +193,10 @@ fn block_border_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -83,6 +207,10 @@ fn block_border_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -96,22 +224,129 @@ fn block_border_percentage_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_border_percentage_intrinsic_size.rs b/tests/generated/block/block_border_percentage_intrinsic_size.rs index 33a6b4481..2237804a7 100644 --- a/tests/generated/block/block_border_percentage_intrinsic_size.rs +++ b/tests/generated/block/block_border_percentage_intrinsic_size.rs @@ -7,19 +7,34 @@ fn block_border_percentage_intrinsic_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -27,24 +42,131 @@ fn block_border_percentage_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +179,7 @@ fn block_border_percentage_intrinsic_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -66,6 +189,10 @@ fn block_border_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -76,6 +203,10 @@ fn block_border_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -85,22 +216,129 @@ fn block_border_percentage_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_display_none.rs b/tests/generated/block/block_display_none.rs index e45bc142d..399b93423 100644 --- a/tests/generated/block/block_display_none.rs +++ b/tests/generated/block/block_display_none.rs @@ -6,6 +6,7 @@ fn block_display_none__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -13,12 +14,14 @@ fn block_display_none__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -27,6 +30,10 @@ fn block_display_none__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -37,30 +44,164 @@ fn block_display_none__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,6 +213,7 @@ fn block_display_none__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -80,6 +222,7 @@ fn block_display_none__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -87,6 +230,7 @@ fn block_display_none__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -96,6 +240,10 @@ fn block_display_none__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -106,28 +254,162 @@ fn block_display_none__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_display_none_with_child.rs b/tests/generated/block/block_display_none_with_child.rs index d19a40228..5b9d247b2 100644 --- a/tests/generated/block/block_display_none_with_child.rs +++ b/tests/generated/block/block_display_none_with_child.rs @@ -6,12 +6,14 @@ fn block_display_none_with_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,12 +23,20 @@ fn block_display_none_with_child__border_box() { .unwrap(); let node1 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::None, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node10], ) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -35,6 +45,10 @@ fn block_display_none_with_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -48,36 +62,203 @@ fn block_display_none_with_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +270,7 @@ fn block_display_none_with_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -96,6 +278,7 @@ fn block_display_none_with_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -108,6 +291,10 @@ fn block_display_none_with_child__content_box() { taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node10], @@ -116,6 +303,7 @@ fn block_display_none_with_child__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -125,6 +313,10 @@ fn block_display_none_with_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -138,34 +330,201 @@ fn block_display_none_with_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_display_none_with_inset.rs b/tests/generated/block/block_display_none_with_inset.rs index 9daeb9a81..9e87b017b 100644 --- a/tests/generated/block/block_display_none_with_inset.rs +++ b/tests/generated/block/block_display_none_with_inset.rs @@ -6,6 +6,7 @@ fn block_display_none_with_inset__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -13,6 +14,7 @@ fn block_display_none_with_inset__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() }, ..Default::default() @@ -22,6 +24,10 @@ fn block_display_none_with_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -35,24 +41,125 @@ fn block_display_none_with_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +171,7 @@ fn block_display_none_with_inset__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -72,6 +180,7 @@ fn block_display_none_with_inset__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() }, ..Default::default() @@ -82,6 +191,10 @@ fn block_display_none_with_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -95,22 +208,123 @@ fn block_display_none_with_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_display_none_with_margin.rs b/tests/generated/block/block_display_none_with_margin.rs index 2b70ce565..1eda2d43f 100644 --- a/tests/generated/block/block_display_none_with_margin.rs +++ b/tests/generated/block/block_display_none_with_margin.rs @@ -7,6 +7,7 @@ fn block_display_none_with_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -22,6 +23,7 @@ fn block_display_none_with_margin__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -30,6 +32,10 @@ fn block_display_none_with_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -43,24 +49,125 @@ fn block_display_none_with_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +180,7 @@ fn block_display_none_with_margin__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +197,7 @@ fn block_display_none_with_margin__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +207,10 @@ fn block_display_none_with_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -111,22 +224,123 @@ fn block_display_none_with_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_display_none_with_position_absolute.rs b/tests/generated/block/block_display_none_with_position_absolute.rs index f145807f2..a5c635029 100644 --- a/tests/generated/block/block_display_none_with_position_absolute.rs +++ b/tests/generated/block/block_display_none_with_position_absolute.rs @@ -8,6 +8,7 @@ fn block_display_none_with_position_absolute__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -19,6 +20,10 @@ fn block_display_none_with_position_absolute__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn block_display_none_with_position_absolute__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn block_display_none_with_position_absolute__content_box() { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -69,6 +143,10 @@ fn block_display_none_with_position_absolute__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn block_display_none_with_position_absolute__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_inflow_overflow_clip.rs b/tests/generated/block/block_inflow_overflow_clip.rs new file mode 100644 index 000000000..b6a4fcc36 --- /dev/null +++ b/tests/generated/block/block_inflow_overflow_clip.rs @@ -0,0 +1,281 @@ +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 68f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 68f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 46f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 46f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_inflow_overflow_hidden.rs b/tests/generated/block/block_inflow_overflow_hidden.rs new file mode 100644 index 000000000..df1ebc8f3 --- /dev/null +++ b/tests/generated/block/block_inflow_overflow_hidden.rs @@ -0,0 +1,289 @@ +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 72f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 64f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 64f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_inflow_overflow_scroll.rs b/tests/generated/block/block_inflow_overflow_scroll.rs new file mode 100644 index 000000000..f0046a795 --- /dev/null +++ b/tests/generated/block/block_inflow_overflow_scroll.rs @@ -0,0 +1,289 @@ +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 87f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 87f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 79f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 79f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 65f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_inflow_overflow_visible.rs b/tests/generated/block/block_inflow_overflow_visible.rs new file mode 100644 index 000000000..e4f48a276 --- /dev/null +++ b/tests/generated/block/block_inflow_overflow_visible.rs @@ -0,0 +1,287 @@ +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 68f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 68f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn block_inflow_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 46f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 46f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/block/block_inset_fixed.rs b/tests/generated/block/block_inset_fixed.rs index 2885440f5..1af9b4938 100644 --- a/tests/generated/block/block_inset_fixed.rs +++ b/tests/generated/block/block_inset_fixed.rs @@ -6,6 +6,7 @@ fn block_inset_fixed__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: length(2f32), right: auto(), top: length(4f32), bottom: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_inset_fixed__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: length(6f32), top: auto(), bottom: length(8f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_inset_fixed__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: length(2f32), @@ -34,6 +37,10 @@ fn block_inset_fixed__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +51,164 @@ fn block_inset_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 4f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 4f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); - assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node0, 4f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, -6f32, "x of node {:?}. Expected {}. Actual {}", node1, -6f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -6f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node2, 2f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node2, 24f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 24f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +220,7 @@ fn block_inset_fixed__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: length(2f32), right: auto(), top: length(4f32), bottom: auto() }, ..Default::default() @@ -87,6 +229,7 @@ fn block_inset_fixed__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: length(6f32), top: auto(), bottom: length(8f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn block_inset_fixed__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: length(2f32), @@ -110,6 +254,10 @@ fn block_inset_fixed__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +268,162 @@ fn block_inset_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 4f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 4f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); - assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node0, 4f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, -6f32, "x of node {:?}. Expected {}. Actual {}", node1, -6f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -6f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node2, 2f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node2, 24f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 24f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_inset_percentage.rs b/tests/generated/block/block_inset_percentage.rs index ceb9c15da..2a267329a 100644 --- a/tests/generated/block/block_inset_percentage.rs +++ b/tests/generated/block/block_inset_percentage.rs @@ -6,6 +6,7 @@ fn block_inset_percentage__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: percent(0.02f32), @@ -18,6 +19,7 @@ fn block_inset_percentage__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), @@ -30,6 +32,7 @@ fn block_inset_percentage__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: percent(0.02f32), @@ -44,6 +47,10 @@ fn block_inset_percentage__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -54,30 +61,164 @@ fn block_inset_percentage__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, -3f32, "x of node {:?}. Expected {}. Actual {}", node1, -3f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node2, 1f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +230,7 @@ fn block_inset_percentage__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: percent(0.02f32), @@ -102,6 +244,7 @@ fn block_inset_percentage__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), @@ -115,6 +258,7 @@ fn block_inset_percentage__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: percent(0.02f32), @@ -130,6 +274,10 @@ fn block_inset_percentage__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -140,28 +288,162 @@ fn block_inset_percentage__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, -3f32, "x of node {:?}. Expected {}. Actual {}", node1, -3f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node2, 1f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_intrinsic_width.rs b/tests/generated/block/block_intrinsic_width.rs index 95e685346..a2d0ea7ca 100644 --- a/tests/generated/block/block_intrinsic_width.rs +++ b/tests/generated/block/block_intrinsic_width.rs @@ -6,6 +6,7 @@ fn block_intrinsic_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,13 +16,21 @@ fn block_intrinsic_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -29,24 +38,125 @@ fn block_intrinsic_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +168,7 @@ fn block_intrinsic_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -68,6 +179,7 @@ fn block_intrinsic_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -77,6 +189,10 @@ fn block_intrinsic_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -86,22 +202,123 @@ fn block_intrinsic_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_item_max_width.rs b/tests/generated/block/block_item_max_width.rs index 2b3903333..c28d0161f 100644 --- a/tests/generated/block/block_item_max_width.rs +++ b/tests/generated/block/block_item_max_width.rs @@ -6,6 +6,7 @@ fn block_item_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_item_max_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -22,6 +24,10 @@ fn block_item_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -35,24 +41,125 @@ fn block_item_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +171,7 @@ fn block_item_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -72,6 +180,7 @@ fn block_item_max_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -82,6 +191,10 @@ fn block_item_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -95,22 +208,123 @@ fn block_item_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_item_min_width_overrides_max_width.rs b/tests/generated/block/block_item_min_width_overrides_max_width.rs index fbf8a2a14..772b54838 100644 --- a/tests/generated/block/block_item_min_width_overrides_max_width.rs +++ b/tests/generated/block/block_item_min_width_overrides_max_width.rs @@ -6,6 +6,7 @@ fn block_item_min_width_overrides_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, @@ -16,6 +17,10 @@ fn block_item_min_width_overrides_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn block_item_min_width_overrides_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn block_item_min_width_overrides_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, @@ -63,6 +137,10 @@ fn block_item_min_width_overrides_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn block_item_min_width_overrides_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_item_text_align_center.rs b/tests/generated/block/block_item_text_align_center.rs index 17096346e..6bef04a91 100644 --- a/tests/generated/block/block_item_text_align_center.rs +++ b/tests/generated/block/block_item_text_align_center.rs @@ -6,6 +6,7 @@ fn block_item_text_align_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_item_text_align_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -23,6 +25,10 @@ fn block_item_text_align_center__border_box() { taffy::style::Style { display: taffy::style::Display::Block, text_align: taffy::style::TextAlign::LegacyCenter, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -36,24 +42,125 @@ fn block_item_text_align_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +172,7 @@ fn block_item_text_align_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -73,6 +181,7 @@ fn block_item_text_align_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -84,6 +193,10 @@ fn block_item_text_align_center__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, text_align: taffy::style::TextAlign::LegacyCenter, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -97,22 +210,123 @@ fn block_item_text_align_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_item_text_align_left.rs b/tests/generated/block/block_item_text_align_left.rs index 63abf5384..6b036c42b 100644 --- a/tests/generated/block/block_item_text_align_left.rs +++ b/tests/generated/block/block_item_text_align_left.rs @@ -6,6 +6,7 @@ fn block_item_text_align_left__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_item_text_align_left__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -23,6 +25,10 @@ fn block_item_text_align_left__border_box() { taffy::style::Style { display: taffy::style::Display::Block, text_align: taffy::style::TextAlign::LegacyLeft, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -36,24 +42,125 @@ fn block_item_text_align_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +172,7 @@ fn block_item_text_align_left__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -73,6 +181,7 @@ fn block_item_text_align_left__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -84,6 +193,10 @@ fn block_item_text_align_left__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, text_align: taffy::style::TextAlign::LegacyLeft, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -97,22 +210,123 @@ fn block_item_text_align_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_item_text_align_right.rs b/tests/generated/block/block_item_text_align_right.rs index 3491f5da0..db4ffcaaf 100644 --- a/tests/generated/block/block_item_text_align_right.rs +++ b/tests/generated/block/block_item_text_align_right.rs @@ -6,6 +6,7 @@ fn block_item_text_align_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_item_text_align_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -23,6 +25,10 @@ fn block_item_text_align_right__border_box() { taffy::style::Style { display: taffy::style::Display::Block, text_align: taffy::style::TextAlign::LegacyRight, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -36,24 +42,125 @@ fn block_item_text_align_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +172,7 @@ fn block_item_text_align_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -73,6 +181,7 @@ fn block_item_text_align_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -84,6 +193,10 @@ fn block_item_text_align_right__content_box() { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, text_align: taffy::style::TextAlign::LegacyRight, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -97,22 +210,123 @@ fn block_item_text_align_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_bottom.rs b/tests/generated/block/block_margin_auto_bottom.rs index a96c7f2e7..46d738232 100644 --- a/tests/generated/block/block_margin_auto_bottom.rs +++ b/tests/generated/block/block_margin_auto_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_auto_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_bottom__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,24 +52,125 @@ fn block_margin_auto_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn block_margin_auto_bottom__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -91,6 +199,7 @@ fn block_margin_auto_bottom__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +212,10 @@ fn block_margin_auto_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -117,22 +230,123 @@ fn block_margin_auto_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_bottom_and_top.rs b/tests/generated/block/block_margin_auto_bottom_and_top.rs index bb03e457a..eeb31bf7d 100644 --- a/tests/generated/block/block_margin_auto_bottom_and_top.rs +++ b/tests/generated/block/block_margin_auto_bottom_and_top.rs @@ -6,6 +6,7 @@ fn block_margin_auto_bottom_and_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_bottom_and_top__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_bottom_and_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn block_margin_auto_bottom_and_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn block_margin_auto_bottom_and_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn block_margin_auto_bottom_and_top__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -102,6 +211,10 @@ fn block_margin_auto_bottom_and_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn block_margin_auto_bottom_and_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left.rs b/tests/generated/block/block_margin_auto_left.rs index 2c21bd02b..39791459b 100644 --- a/tests/generated/block/block_margin_auto_left.rs +++ b/tests/generated/block/block_margin_auto_left.rs @@ -6,6 +6,7 @@ fn block_margin_auto_left__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_left__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_left__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn block_margin_auto_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node0, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn block_margin_auto_left__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn block_margin_auto_left__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -102,6 +211,10 @@ fn block_margin_auto_left__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn block_margin_auto_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node0, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left_and_right.rs b/tests/generated/block/block_margin_auto_left_and_right.rs index 64c63fce1..b29c6fa1d 100644 --- a/tests/generated/block/block_margin_auto_left_and_right.rs +++ b/tests/generated/block/block_margin_auto_left_and_right.rs @@ -6,6 +6,7 @@ fn block_margin_auto_left_and_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_left_and_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_left_and_right__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn block_margin_auto_left_and_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn block_margin_auto_left_and_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn block_margin_auto_left_and_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -102,6 +211,10 @@ fn block_margin_auto_left_and_right__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn block_margin_auto_left_and_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs b/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs index 8dab85b78..19ca1991f 100644 --- a/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs +++ b/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs @@ -7,6 +7,10 @@ fn block_margin_auto_left_and_right_with_auto_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::AUTO, height: taffy::style::Dimension::from_length(50f32), @@ -27,6 +31,10 @@ fn block_margin_auto_left_and_right_with_auto_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -40,18 +48,86 @@ fn block_margin_auto_left_and_right_with_auto_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +140,10 @@ fn block_margin_auto_left_and_right_with_auto_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::AUTO, height: taffy::style::Dimension::from_length(50f32), @@ -85,6 +165,10 @@ fn block_margin_auto_left_and_right_with_auto_width__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -98,16 +182,84 @@ fn block_margin_auto_left_and_right_with_auto_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs b/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs index fd20d4f20..540840163 100644 --- a/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs +++ b/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn block_margin_auto_left_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -23,6 +24,10 @@ fn block_margin_auto_left_child_bigger_than_parent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn block_margin_auto_left_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_margin_auto_left_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -77,6 +151,10 @@ fn block_margin_auto_left_child_bigger_than_parent__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn block_margin_auto_left_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs index cd7c146d1..3813162e9 100644 --- a/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -23,6 +24,10 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -77,6 +151,10 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs index 539f69234..81d264629 100644 --- a/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs +++ b/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn block_margin_auto_left_right_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -23,6 +24,10 @@ fn block_margin_auto_left_right_child_bigger_than_parent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn block_margin_auto_left_right_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn block_margin_auto_left_right_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -77,6 +151,10 @@ fn block_margin_auto_left_right_child_bigger_than_parent__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn block_margin_auto_left_right_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_multiple_children.rs b/tests/generated/block/block_margin_auto_multiple_children.rs index 075aee961..a533cf5e6 100644 --- a/tests/generated/block/block_margin_auto_multiple_children.rs +++ b/tests/generated/block/block_margin_auto_multiple_children.rs @@ -6,6 +6,7 @@ fn block_margin_auto_multiple_children__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_multiple_children__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -36,6 +38,7 @@ fn block_margin_auto_multiple_children__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -47,6 +50,10 @@ fn block_margin_auto_multiple_children__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -61,30 +68,164 @@ fn block_margin_auto_multiple_children__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -96,6 +237,7 @@ fn block_margin_auto_multiple_children__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -112,6 +254,7 @@ fn block_margin_auto_multiple_children__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -128,6 +271,7 @@ fn block_margin_auto_multiple_children__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -140,6 +284,10 @@ fn block_margin_auto_multiple_children__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -154,28 +302,162 @@ fn block_margin_auto_multiple_children__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_right.rs b/tests/generated/block/block_margin_auto_right.rs index f393ace3a..4d4f40b81 100644 --- a/tests/generated/block/block_margin_auto_right.rs +++ b/tests/generated/block/block_margin_auto_right.rs @@ -6,6 +6,7 @@ fn block_margin_auto_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_right__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,24 +52,125 @@ fn block_margin_auto_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn block_margin_auto_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -91,6 +199,7 @@ fn block_margin_auto_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +212,10 @@ fn block_margin_auto_right__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -117,22 +230,123 @@ fn block_margin_auto_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_auto_top.rs b/tests/generated/block/block_margin_auto_top.rs index cc24183ea..272885b3b 100644 --- a/tests/generated/block/block_margin_auto_top.rs +++ b/tests/generated/block/block_margin_auto_top.rs @@ -6,6 +6,7 @@ fn block_margin_auto_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn block_margin_auto_top__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn block_margin_auto_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,24 +52,125 @@ fn block_margin_auto_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn block_margin_auto_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -91,6 +199,7 @@ fn block_margin_auto_top__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +212,10 @@ fn block_margin_auto_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -117,22 +230,123 @@ fn block_margin_auto_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_auto_bottom.rs b/tests/generated/block/block_margin_x_fixed_auto_bottom.rs index 0635673d3..1591d1d10 100644 --- a/tests/generated/block/block_margin_x_fixed_auto_bottom.rs +++ b/tests/generated/block/block_margin_x_fixed_auto_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_auto_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_x_fixed_auto_bottom__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_x_fixed_auto_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_x_fixed_auto_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_x_fixed_auto_bottom__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_x_fixed_auto_bottom__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_x_fixed_auto_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_x_fixed_auto_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_auto_left.rs b/tests/generated/block/block_margin_x_fixed_auto_left.rs index 571e087d6..0a6fcc960 100644 --- a/tests/generated/block/block_margin_x_fixed_auto_left.rs +++ b/tests/generated/block/block_margin_x_fixed_auto_left.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_auto_left__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_x_fixed_auto_left__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_x_fixed_auto_left__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_x_fixed_auto_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_x_fixed_auto_left__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_x_fixed_auto_left__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_x_fixed_auto_left__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_x_fixed_auto_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs b/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs index c5c05dde3..3e4b03631 100644 --- a/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs +++ b/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_auto_left_and_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_x_fixed_auto_left_and_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_x_fixed_auto_left_and_right__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_x_fixed_auto_left_and_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_x_fixed_auto_left_and_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_x_fixed_auto_left_and_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_x_fixed_auto_left_and_right__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_x_fixed_auto_left_and_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_auto_right.rs b/tests/generated/block/block_margin_x_fixed_auto_right.rs index c77c13385..2244e7588 100644 --- a/tests/generated/block/block_margin_x_fixed_auto_right.rs +++ b/tests/generated/block/block_margin_x_fixed_auto_right.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_auto_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_x_fixed_auto_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_x_fixed_auto_right__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_x_fixed_auto_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_x_fixed_auto_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_x_fixed_auto_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_x_fixed_auto_right__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_x_fixed_auto_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_auto_top.rs b/tests/generated/block/block_margin_x_fixed_auto_top.rs index 3d75559b9..b00efe4e6 100644 --- a/tests/generated/block/block_margin_x_fixed_auto_top.rs +++ b/tests/generated/block/block_margin_x_fixed_auto_top.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_auto_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_x_fixed_auto_top__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_x_fixed_auto_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_x_fixed_auto_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_x_fixed_auto_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_x_fixed_auto_top__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_x_fixed_auto_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_x_fixed_auto_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_size_negative.rs b/tests/generated/block/block_margin_x_fixed_size_negative.rs index 8b5a370fe..eea43b878 100644 --- a/tests/generated/block/block_margin_x_fixed_size_negative.rs +++ b/tests/generated/block/block_margin_x_fixed_size_negative.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_size_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(-10f32), right: length(-5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_x_fixed_size_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn block_margin_x_fixed_size_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -31,24 +37,125 @@ fn block_margin_x_fixed_size_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +167,7 @@ fn block_margin_x_fixed_size_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(-10f32), right: length(-5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -68,6 +176,7 @@ fn block_margin_x_fixed_size_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -77,6 +186,10 @@ fn block_margin_x_fixed_size_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -87,22 +200,123 @@ fn block_margin_x_fixed_size_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_fixed_size_positive.rs b/tests/generated/block/block_margin_x_fixed_size_positive.rs index 0b153765c..a50d54eee 100644 --- a/tests/generated/block/block_margin_x_fixed_size_positive.rs +++ b/tests/generated/block/block_margin_x_fixed_size_positive.rs @@ -6,6 +6,7 @@ fn block_margin_x_fixed_size_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(10f32), right: length(5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_x_fixed_size_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn block_margin_x_fixed_size_positive__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -31,24 +37,125 @@ fn block_margin_x_fixed_size_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +167,7 @@ fn block_margin_x_fixed_size_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(10f32), right: length(5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -68,6 +176,7 @@ fn block_margin_x_fixed_size_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -77,6 +186,10 @@ fn block_margin_x_fixed_size_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -87,22 +200,123 @@ fn block_margin_x_fixed_size_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_intrinsic_size_negative.rs b/tests/generated/block/block_margin_x_intrinsic_size_negative.rs index 7dfadd532..69cc2e349 100644 --- a/tests/generated/block/block_margin_x_intrinsic_size_negative.rs +++ b/tests/generated/block/block_margin_x_intrinsic_size_negative.rs @@ -6,6 +6,7 @@ fn block_margin_x_intrinsic_size_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(-10f32), right: length(-5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -13,13 +14,21 @@ fn block_margin_x_intrinsic_size_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -27,24 +36,125 @@ fn block_margin_x_intrinsic_size_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node0, 15f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +166,7 @@ fn block_margin_x_intrinsic_size_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(-10f32), right: length(-5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -64,6 +175,7 @@ fn block_margin_x_intrinsic_size_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -73,6 +185,10 @@ fn block_margin_x_intrinsic_size_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -82,22 +198,123 @@ fn block_margin_x_intrinsic_size_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node0, 15f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_intrinsic_size_positive.rs b/tests/generated/block/block_margin_x_intrinsic_size_positive.rs index ae2846c72..86d355c8e 100644 --- a/tests/generated/block/block_margin_x_intrinsic_size_positive.rs +++ b/tests/generated/block/block_margin_x_intrinsic_size_positive.rs @@ -6,6 +6,7 @@ fn block_margin_x_intrinsic_size_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(10f32), right: length(5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -13,13 +14,21 @@ fn block_margin_x_intrinsic_size_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -27,24 +36,125 @@ fn block_margin_x_intrinsic_size_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node, 15f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node1, 15f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +166,7 @@ fn block_margin_x_intrinsic_size_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: length(10f32), right: length(5f32), top: zero(), bottom: zero() }, ..Default::default() @@ -64,6 +175,7 @@ fn block_margin_x_intrinsic_size_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -73,6 +185,10 @@ fn block_margin_x_intrinsic_size_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -82,22 +198,123 @@ fn block_margin_x_intrinsic_size_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node, 15f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node1, 15f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs b/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs index ca161b10f..a57ed8c15 100644 --- a/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs +++ b/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_fixed_size_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(-0.2f32), @@ -18,6 +19,7 @@ fn block_margin_x_percentage_fixed_size_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +28,10 @@ fn block_margin_x_percentage_fixed_size_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -36,24 +42,125 @@ fn block_margin_x_percentage_fixed_size_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +172,7 @@ fn block_margin_x_percentage_fixed_size_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(-0.2f32), @@ -78,6 +186,7 @@ fn block_margin_x_percentage_fixed_size_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -87,6 +196,10 @@ fn block_margin_x_percentage_fixed_size_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -97,22 +210,123 @@ fn block_margin_x_percentage_fixed_size_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs b/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs index ecb7562a0..5b64830a9 100644 --- a/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs +++ b/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_fixed_size_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -18,6 +19,7 @@ fn block_margin_x_percentage_fixed_size_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +28,10 @@ fn block_margin_x_percentage_fixed_size_positive__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -36,24 +42,125 @@ fn block_margin_x_percentage_fixed_size_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +172,7 @@ fn block_margin_x_percentage_fixed_size_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -78,6 +186,7 @@ fn block_margin_x_percentage_fixed_size_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -87,6 +196,10 @@ fn block_margin_x_percentage_fixed_size_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -97,22 +210,123 @@ fn block_margin_x_percentage_fixed_size_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs b/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs index 35bc0c7ae..63e76a2fb 100644 --- a/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs +++ b/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(-0.2f32), @@ -18,6 +19,7 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,7 +29,14 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -35,24 +44,125 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +174,7 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(-0.2f32), @@ -77,6 +188,7 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -89,6 +201,10 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -98,22 +214,123 @@ fn block_margin_x_percentage_intrinsic_size_other_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs b/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs index bf316afe8..1281f1259 100644 --- a/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs +++ b/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -18,6 +19,7 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,7 +29,14 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -35,24 +44,125 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +174,7 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -77,6 +188,7 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -89,6 +201,10 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -98,22 +214,123 @@ fn block_margin_x_percentage_intrinsic_size_other_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs b/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs index 9f5fa609e..d767b8a18 100644 --- a/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs +++ b/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,7 +22,14 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -29,18 +37,86 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +128,7 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -70,6 +147,10 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -79,16 +160,84 @@ fn block_margin_x_percentage_intrinsic_size_self_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs b/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs index a23546d8f..e0c0d9c68 100644 --- a/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs +++ b/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs @@ -6,6 +6,7 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,7 +22,14 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -29,18 +37,86 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +128,7 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -70,6 +147,10 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -79,16 +160,84 @@ fn block_margin_x_percentage_intrinsic_size_self_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_complex.rs b/tests/generated/block/block_margin_y_collapse_complex.rs index 27a4a22c0..c2ffd7eb6 100644 --- a/tests/generated/block/block_margin_y_collapse_complex.rs +++ b/tests/generated/block/block_margin_y_collapse_complex.rs @@ -6,6 +6,7 @@ fn block_margin_y_collapse_complex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_collapse_complex__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_margin_y_collapse_complex__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: length(3f32) }, ..Default::default() @@ -27,6 +30,7 @@ fn block_margin_y_collapse_complex__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-6f32), bottom: length(9f32) }, ..Default::default() @@ -35,6 +39,10 @@ fn block_margin_y_collapse_complex__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -49,6 +57,7 @@ fn block_margin_y_collapse_complex__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -56,6 +65,7 @@ fn block_margin_y_collapse_complex__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -65,6 +75,10 @@ fn block_margin_y_collapse_complex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -75,54 +89,338 @@ fn block_margin_y_collapse_complex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), -6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -134,6 +432,7 @@ fn block_margin_y_collapse_complex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -142,6 +441,7 @@ fn block_margin_y_collapse_complex__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -150,6 +450,7 @@ fn block_margin_y_collapse_complex__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: length(3f32) }, ..Default::default() @@ -158,6 +459,7 @@ fn block_margin_y_collapse_complex__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-6f32), bottom: length(9f32) }, ..Default::default() @@ -167,6 +469,10 @@ fn block_margin_y_collapse_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -182,6 +488,7 @@ fn block_margin_y_collapse_complex__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -190,6 +497,7 @@ fn block_margin_y_collapse_complex__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -200,6 +508,10 @@ fn block_margin_y_collapse_complex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -210,52 +522,336 @@ fn block_margin_y_collapse_complex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), -6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs index 44ab4173c..13e9938be 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(2f32), margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -23,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -32,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -42,30 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -87,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(2f32), margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -96,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -106,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -116,28 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs index b83565b6d..63bc20b46 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs index 81a787c67..f00584fa5 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_collapse_through_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn block_margin_y_collapse_through_blocked_by_border_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn block_margin_y_collapse_through_blocked_by_border_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn block_margin_y_collapse_through_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn block_margin_y_collapse_through_blocked_by_border_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs index e8cb89cca..8ffe9b973 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_height__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -23,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_height__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -32,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -42,30 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -87,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -96,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -106,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -116,28 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs index afc74f8c4..4e20d1363 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box__border_box() { .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), @@ -30,6 +35,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -39,6 +45,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,30 +59,164 @@ fn block_margin_y_collapse_through_blocked_by_line_box__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -85,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -95,6 +240,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), @@ -110,6 +259,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -120,6 +270,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -130,28 +284,162 @@ fn block_margin_y_collapse_through_blocked_by_line_box__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs index 63d21bff2..9fb9289aa 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__border_ let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__border_ .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -31,6 +36,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__border_ let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -40,6 +46,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__border_ .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -50,30 +60,164 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__border_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +230,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__content .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -96,6 +241,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__content taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -112,6 +261,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__content .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -122,6 +272,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__content taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -132,28 +286,162 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero__content println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs index ef7454970..a1c96066b 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__bor let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__bor .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -31,6 +36,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__bor let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -40,6 +46,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__bor .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -50,30 +60,164 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__bor println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +230,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__con .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -96,6 +241,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__con taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -112,6 +261,7 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__con .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -122,6 +272,10 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__con taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -132,28 +286,162 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero__con println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs index 6d62f4478..7469e9c40 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -23,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -32,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -42,30 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -87,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -96,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_min_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -106,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -116,28 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs index fde281837..ee51ac51f 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -24,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -33,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -43,48 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -116,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -126,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -136,46 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs index cbd0f8c9e..558d127af 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -24,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -33,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -43,48 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 55f32, "height of node {:?}. Expected {}. Actual {}", node, 55f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 55f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -116,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -126,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -136,46 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 55f32, "height of node {:?}. Expected {}. Actual {}", node, 55f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 55f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs index 73d1abc1e..30bc3d9cd 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -24,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -33,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -43,48 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -116,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -126,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -136,46 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs index 9486ecbda..93f960755 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -24,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -33,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -43,48 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -116,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -126,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -136,46 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs index 19a394d88..e5182fa20 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -23,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -32,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -42,30 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -87,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -96,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -106,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -116,28 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs b/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs index fca166177..f6306a43e 100644 --- a/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs +++ b/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -23,6 +25,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -32,6 +35,10 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -42,30 +49,164 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -87,6 +229,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -96,6 +239,7 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -106,6 +250,10 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -116,28 +264,162 @@ fn block_margin_y_collapse_through_blocked_by_padding_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 1f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_negative.rs b/tests/generated/block/block_margin_y_collapse_through_negative.rs index c2c2583bf..75a6b1491 100644 --- a/tests/generated/block/block_margin_y_collapse_through_negative.rs +++ b/tests/generated/block/block_margin_y_collapse_through_negative.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_negative__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_negative__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-7f32), bottom: length(-3f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_collapse_through_negative__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-2f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_collapse_through_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn block_margin_y_collapse_through_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 13f32, "height of node {:?}. Expected {}. Actual {}", node, 13f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 13f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node1, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node2, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn block_margin_y_collapse_through_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn block_margin_y_collapse_through_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-7f32), bottom: length(-3f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn block_margin_y_collapse_through_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-2f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn block_margin_y_collapse_through_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn block_margin_y_collapse_through_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 13f32, "height of node {:?}. Expected {}. Actual {}", node, 13f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 13f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node1, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node2, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_positive.rs b/tests/generated/block/block_margin_y_collapse_through_positive.rs index b20cc4906..41bcbd00a 100644 --- a/tests/generated/block/block_margin_y_collapse_through_positive.rs +++ b/tests/generated/block/block_margin_y_collapse_through_positive.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_positive__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_positive__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_collapse_through_positive__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_collapse_through_positive__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn block_margin_y_collapse_through_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn block_margin_y_collapse_through_positive__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn block_margin_y_collapse_through_positive__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn block_margin_y_collapse_through_positive__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn block_margin_y_collapse_through_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn block_margin_y_collapse_through_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs b/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs index f43dc77c4..4543276bf 100644 --- a/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs +++ b/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_positive_and_negative__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_collapse_through_positive_and_negative__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(-4f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_collapse_through_positive_and_negative__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_collapse_through_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn block_margin_y_collapse_through_positive_and_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node2, 7f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn block_margin_y_collapse_through_positive_and_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn block_margin_y_collapse_through_positive_and_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(-4f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn block_margin_y_collapse_through_positive_and_negative__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn block_margin_y_collapse_through_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn block_margin_y_collapse_through_positive_and_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node2, 7f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs b/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs index b10bfccc9..79899c6d9 100644 --- a/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs +++ b/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs @@ -7,6 +7,7 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -14,7 +15,14 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { .unwrap(); let node10 = taffy .new_leaf_with_context( - taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -22,6 +30,10 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), @@ -36,6 +48,7 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -45,6 +58,10 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -55,36 +72,209 @@ fn block_margin_y_collapse_through_with_absolute_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +287,7 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -107,6 +298,10 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), @@ -117,6 +312,10 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), @@ -132,6 +331,7 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -142,6 +342,10 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -152,34 +356,207 @@ fn block_margin_y_collapse_through_with_absolute_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs index e6ab060c9..f85be50f3 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs index ddffccdd3..9b2634720 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__border_box( let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__content_box let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs index 5789c3635..55139cb6f 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__border_box( let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__content_box let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs index 661876afa..51ea7f4c1 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__border_box( let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__content_box let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs index d2dd3ef09..c3fc49c40 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__border_box( let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__content_box let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs index 154c9725a..c323acd75 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -35,6 +44,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -45,30 +58,176 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +249,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -100,6 +264,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -112,6 +280,10 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -122,28 +294,174 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs b/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs index 204b242b5..be665c05b 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_negative_equal__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_negative_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_negative_equal__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_negative_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs b/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs index 65630a707..b35e8e98d 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_negative_parent_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs b/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs index e1139d8ff..9fed4f324 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs b/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs index aeee9cffe..246687850 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__border_box( let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__content_box let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs b/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs index 78b557afd..01190929d 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__border_box let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__border_box .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__border_box .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -35,6 +44,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__border_box .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -45,30 +58,176 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__border_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 11f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__content_bo let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +249,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__content_bo taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -100,6 +264,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__content_bo taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -112,6 +280,10 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__content_bo taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -122,28 +294,174 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom__content_bo println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 11f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs b/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs index 97e5d4198..2828ccb69 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -32,6 +41,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .unwrap(); let node100 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -40,6 +50,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -50,6 +64,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -58,6 +76,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .unwrap(); let node200 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -66,6 +85,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -76,6 +99,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -86,6 +113,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -96,66 +127,434 @@ fn block_margin_y_first_child_collapse_positive_and_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -167,6 +566,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -176,6 +576,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -187,6 +591,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -196,6 +604,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { let node100 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -205,6 +614,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -216,6 +629,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -225,6 +642,7 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { let node200 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -234,6 +652,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -245,6 +667,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: zero() }, ..Default::default() }, @@ -256,6 +682,10 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -266,64 +696,432 @@ fn block_margin_y_first_child_collapse_positive_and_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs b/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs index 31f71c98a..19e31c0a5 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_positive_equal__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_positive_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_positive_equal__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_positive_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs b/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs index 448d7102c..fff1a5943 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_positive_parent_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs b/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs index 146b8f58b..92e54ebed 100644 --- a/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs +++ b/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs b/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs index a3d775ca6..ca2c8f5c6 100644 --- a/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs +++ b/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -42,6 +55,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .unwrap(); let node1000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -50,6 +64,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-2f32), bottom: zero() }, ..Default::default() }, @@ -60,6 +78,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -70,6 +92,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -78,6 +104,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .unwrap(); let node2000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -86,6 +113,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(15f32), bottom: zero() }, ..Default::default() }, @@ -96,6 +127,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -106,6 +141,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -116,6 +155,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -126,84 +169,587 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -215,6 +761,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() let node0000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -224,6 +771,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -235,6 +786,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -246,6 +801,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -255,6 +814,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() let node1000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -264,6 +824,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-2f32), bottom: zero() }, ..Default::default() }, @@ -275,6 +839,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -286,6 +854,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -295,6 +867,7 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() let node2000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -304,6 +877,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(15f32), bottom: zero() }, ..Default::default() }, @@ -315,6 +892,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: zero() }, ..Default::default() }, @@ -326,6 +907,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: zero() }, ..Default::default() }, @@ -337,6 +922,10 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -347,82 +936,585 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative__content_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs b/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs index 864d3e2d0..e318e4555 100644 --- a/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs +++ b/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { let mut taffy = crate::new_test_tree(); let node0000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -44,6 +57,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -54,36 +71,227 @@ fn block_margin_y_first_granchild_collapse_positive_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +303,7 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { let node0000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -104,6 +313,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -115,6 +328,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -126,6 +343,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -137,6 +358,10 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -147,34 +372,225 @@ fn block_margin_y_first_granchild_collapse_positive_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs index 1c70fbe4d..16c657d55 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs index 8fd5a69b6..5febe1e5e 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__border_box() let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__content_box( let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden__content_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs index 6dad4f277..3630460cd 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__border_box() let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__content_box( let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll__content_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs index a4c6f8ea9..7f607d41d 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__border_box() let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__content_box( let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden__content_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs index bb50a0fa6..a517aa40d 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__border_box() let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -39,6 +44,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__border_box() .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -49,48 +58,176 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +239,7 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__content_box( let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -111,6 +249,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -138,6 +280,10 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__content_box( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -148,46 +294,174 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll__content_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs index fd3df03c6..1c2a0d931 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -35,6 +44,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -45,30 +58,176 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +249,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -100,6 +264,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(1f32) }, ..Default::default() @@ -112,6 +280,10 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -122,28 +294,174 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs b/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs index 64fcf2f60..fed0b46c1 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_negative_equal__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_negative_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_negative_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_negative_equal__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_negative_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_negative_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs b/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs index 7252bad38..285705ab6 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_negative_parent_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs b/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs index 1f7c99eab..7a212acb0 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs b/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs index 5e213b840..a9757c60b 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs b/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs index 6968aab39..942a934f5 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -35,6 +44,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -45,30 +58,176 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 11f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__content_box() let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +249,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -100,6 +264,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: length(1f32), bottom: zero() }, ..Default::default() @@ -112,6 +280,10 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__content_box() taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -122,28 +294,174 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top__content_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 21f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 11f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs b/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs index 4d8fa8c2e..088feeaff 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -32,6 +41,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .unwrap(); let node100 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -40,6 +50,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -50,6 +64,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -58,6 +76,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .unwrap(); let node200 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -66,6 +85,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -76,6 +99,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -86,6 +113,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -96,66 +127,434 @@ fn block_margin_y_last_child_collapse_positive_and_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node2, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -167,6 +566,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -176,6 +576,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -187,6 +591,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -196,6 +604,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { let node100 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -205,6 +614,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -216,6 +629,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-10f32) }, ..Default::default() }, @@ -225,6 +642,7 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { let node200 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -234,6 +652,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -245,6 +667,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(-5f32) }, ..Default::default() }, @@ -256,6 +682,10 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -266,64 +696,432 @@ fn block_margin_y_last_child_collapse_positive_and_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node2, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node200).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node200, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node200, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs b/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs index 1ac41b310..20629b02d 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_positive_equal__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_positive_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_positive_equal__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_positive_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs b/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs index ce3f70d4d..31ba23720 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_positive_parent_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs b/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs index ba55991d0..0058fd3a2 100644 --- a/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs +++ b/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(5f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs b/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs index ee4f0c6a9..809c915c3 100644 --- a/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs +++ b/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs @@ -6,6 +6,7 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { let mut taffy = crate::new_test_tree(); let node0000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -44,6 +57,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -54,36 +71,227 @@ fn block_margin_y_last_granchild_collapse_positive_equal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +303,7 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { let node0000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -104,6 +313,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -115,6 +328,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -126,6 +343,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -137,6 +358,10 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -147,34 +372,225 @@ fn block_margin_y_last_granchild_collapse_positive_equal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 50f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_negative.rs b/tests/generated/block/block_margin_y_sibling_collapse_negative.rs index 234306260..8c3a2005b 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_negative.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_sibling_collapse_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_margin_y_sibling_collapse_negative__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -27,6 +30,7 @@ fn block_margin_y_sibling_collapse_negative__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -36,6 +40,10 @@ fn block_margin_y_sibling_collapse_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -46,36 +54,203 @@ fn block_margin_y_sibling_collapse_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +262,7 @@ fn block_margin_y_sibling_collapse_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -95,6 +271,7 @@ fn block_margin_y_sibling_collapse_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -103,6 +280,7 @@ fn block_margin_y_sibling_collapse_negative__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -111,6 +289,7 @@ fn block_margin_y_sibling_collapse_negative__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -121,6 +300,10 @@ fn block_margin_y_sibling_collapse_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -131,34 +314,201 @@ fn block_margin_y_sibling_collapse_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs b/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs index f353cd396..7daf8ce7e 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -18,6 +19,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -30,6 +32,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -42,6 +45,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -56,6 +60,10 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -66,36 +74,203 @@ fn block_margin_y_sibling_collapse_negative_percentage__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -107,6 +282,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -120,6 +296,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -133,6 +310,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -146,6 +324,7 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -161,6 +340,10 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -171,34 +354,201 @@ fn block_margin_y_sibling_collapse_negative_percentage__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_positive.rs b/tests/generated/block/block_margin_y_sibling_collapse_positive.rs index dccebaeed..79feb6e81 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_positive.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_positive.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_sibling_collapse_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_margin_y_sibling_collapse_positive__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(5f32) }, ..Default::default() @@ -27,6 +30,7 @@ fn block_margin_y_sibling_collapse_positive__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -36,6 +40,10 @@ fn block_margin_y_sibling_collapse_positive__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -46,36 +54,203 @@ fn block_margin_y_sibling_collapse_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +262,7 @@ fn block_margin_y_sibling_collapse_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -95,6 +271,7 @@ fn block_margin_y_sibling_collapse_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -103,6 +280,7 @@ fn block_margin_y_sibling_collapse_positive__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(5f32) }, ..Default::default() @@ -111,6 +289,7 @@ fn block_margin_y_sibling_collapse_positive__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -121,6 +300,10 @@ fn block_margin_y_sibling_collapse_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -131,34 +314,201 @@ fn block_margin_y_sibling_collapse_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs b/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs index 399cd39df..61831cbb8 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(10f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(5f32) }, ..Default::default() @@ -27,6 +30,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -34,6 +38,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(-10f32) }, ..Default::default() @@ -41,6 +46,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(-5f32) }, ..Default::default() @@ -48,6 +54,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -57,6 +64,10 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -67,54 +78,320 @@ fn block_margin_y_sibling_collapse_positive_and_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node5, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node6, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -126,6 +403,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -134,6 +412,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(10f32) }, ..Default::default() @@ -142,6 +421,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(5f32) }, ..Default::default() @@ -150,6 +430,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -158,6 +439,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(-10f32) }, ..Default::default() @@ -166,6 +448,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(5f32), bottom: length(-5f32) }, ..Default::default() @@ -174,6 +457,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -184,6 +468,10 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -194,52 +482,318 @@ fn block_margin_y_sibling_collapse_positive_and_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node5, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node6, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs b/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs index 392715dcd..712409a7c 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -18,6 +19,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -30,6 +32,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -42,6 +45,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -54,6 +58,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -66,6 +71,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -78,6 +84,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -92,6 +99,10 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -102,54 +113,320 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 28f32, "y of node {:?}. Expected {}. Actual {}", node2, 28f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 28f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node3, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 53f32, "y of node {:?}. Expected {}. Actual {}", node5, 53f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 53f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node6, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -161,6 +438,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -174,6 +452,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -187,6 +466,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -200,6 +480,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -213,6 +494,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -226,6 +508,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -239,6 +522,7 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -254,6 +538,10 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -264,52 +552,318 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 28f32, "y of node {:?}. Expected {}. Actual {}", node2, 28f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 28f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node3, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 53f32, "y of node {:?}. Expected {}. Actual {}", node5, 53f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 53f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node6, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs b/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs index bf1e4a3de..d197c01f1 100644 --- a/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs +++ b/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs @@ -6,6 +6,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -18,6 +19,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -30,6 +32,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -42,6 +45,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -56,6 +60,10 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -66,36 +74,203 @@ fn block_margin_y_sibling_collapse_positive_percentage__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -107,6 +282,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -120,6 +296,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -133,6 +310,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -146,6 +324,7 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -161,6 +340,10 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -171,34 +354,201 @@ fn block_margin_y_sibling_collapse_positive_percentage__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_negative.rs b/tests/generated/block/block_margin_y_simple_negative.rs index 9bfdbcb1f..1446c4780 100644 --- a/tests/generated/block/block_margin_y_simple_negative.rs +++ b/tests/generated/block/block_margin_y_simple_negative.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_simple_negative__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn block_margin_y_simple_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -31,24 +37,125 @@ fn block_margin_y_simple_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +167,7 @@ fn block_margin_y_simple_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -68,6 +176,7 @@ fn block_margin_y_simple_negative__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -77,6 +186,10 @@ fn block_margin_y_simple_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -87,22 +200,123 @@ fn block_margin_y_simple_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs b/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs index f7c7ae73f..9b1badf5c 100644 --- a/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs +++ b/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_negative_percentage_other__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -18,6 +19,7 @@ fn block_margin_y_simple_negative_percentage_other__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -29,6 +31,10 @@ fn block_margin_y_simple_negative_percentage_other__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_y_simple_negative_percentage_other__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_y_simple_negative_percentage_other__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -81,6 +189,7 @@ fn block_margin_y_simple_negative_percentage_other__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -93,6 +202,10 @@ fn block_margin_y_simple_negative_percentage_other__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_y_simple_negative_percentage_other__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs b/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs index ed8d83092..1a5d5fc51 100644 --- a/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs +++ b/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_negative_percentage_self__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,6 +22,7 @@ fn block_margin_y_simple_negative_percentage_self__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -29,6 +31,10 @@ fn block_margin_y_simple_negative_percentage_self__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn block_margin_y_simple_negative_percentage_self__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_margin_y_simple_negative_percentage_self__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -84,6 +192,7 @@ fn block_margin_y_simple_negative_percentage_self__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -93,6 +202,10 @@ fn block_margin_y_simple_negative_percentage_self__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn block_margin_y_simple_negative_percentage_self__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_positive.rs b/tests/generated/block/block_margin_y_simple_positive.rs index 05d8ec89e..441fe4acd 100644 --- a/tests/generated/block/block_margin_y_simple_positive.rs +++ b/tests/generated/block/block_margin_y_simple_positive.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_positive__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_simple_positive__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn block_margin_y_simple_positive__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -31,24 +37,125 @@ fn block_margin_y_simple_positive__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +167,7 @@ fn block_margin_y_simple_positive__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -68,6 +176,7 @@ fn block_margin_y_simple_positive__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -77,6 +186,10 @@ fn block_margin_y_simple_positive__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -87,22 +200,123 @@ fn block_margin_y_simple_positive__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs b/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs index 143e755ad..b5be2332c 100644 --- a/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs +++ b/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_positive_percentage_other__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -18,6 +19,7 @@ fn block_margin_y_simple_positive_percentage_other__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,7 +29,14 @@ fn block_margin_y_simple_positive_percentage_other__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -35,24 +44,125 @@ fn block_margin_y_simple_positive_percentage_other__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +174,7 @@ fn block_margin_y_simple_positive_percentage_other__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -77,6 +188,7 @@ fn block_margin_y_simple_positive_percentage_other__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -89,6 +201,10 @@ fn block_margin_y_simple_positive_percentage_other__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -98,22 +214,123 @@ fn block_margin_y_simple_positive_percentage_other__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs b/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs index ad04760bd..86571ac0e 100644 --- a/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs +++ b/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs @@ -6,6 +6,7 @@ fn block_margin_y_simple_positive_percentage_self__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,13 +22,21 @@ fn block_margin_y_simple_positive_percentage_self__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -35,24 +44,125 @@ fn block_margin_y_simple_positive_percentage_self__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +174,7 @@ fn block_margin_y_simple_positive_percentage_self__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -80,6 +191,7 @@ fn block_margin_y_simple_positive_percentage_self__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +201,10 @@ fn block_margin_y_simple_positive_percentage_self__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -98,22 +214,123 @@ fn block_margin_y_simple_positive_percentage_self__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_total_collapse.rs b/tests/generated/block/block_margin_y_total_collapse.rs index fc156a130..d2cbe6b42 100644 --- a/tests/generated/block/block_margin_y_total_collapse.rs +++ b/tests/generated/block/block_margin_y_total_collapse.rs @@ -7,6 +7,7 @@ fn block_margin_y_total_collapse__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn block_margin_y_total_collapse__border_box() { let node01 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn block_margin_y_total_collapse__border_box() { let node02 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn block_margin_y_total_collapse__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -47,6 +54,10 @@ fn block_margin_y_total_collapse__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -57,36 +68,215 @@ fn block_margin_y_total_collapse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +289,7 @@ fn block_margin_y_total_collapse__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -108,6 +299,7 @@ fn block_margin_y_total_collapse__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -116,6 +308,7 @@ fn block_margin_y_total_collapse__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -126,6 +319,10 @@ fn block_margin_y_total_collapse__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -143,6 +340,10 @@ fn block_margin_y_total_collapse__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -153,34 +354,213 @@ fn block_margin_y_total_collapse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_margin_y_total_collapse_complex.rs b/tests/generated/block/block_margin_y_total_collapse_complex.rs index de85d35d7..45991a97f 100644 --- a/tests/generated/block/block_margin_y_total_collapse_complex.rs +++ b/tests/generated/block/block_margin_y_total_collapse_complex.rs @@ -6,6 +6,7 @@ fn block_margin_y_total_collapse_complex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn block_margin_y_total_collapse_complex__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn block_margin_y_total_collapse_complex__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: length(3f32) }, ..Default::default() @@ -27,6 +30,7 @@ fn block_margin_y_total_collapse_complex__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-6f32), bottom: length(9f32) }, ..Default::default() @@ -35,6 +39,10 @@ fn block_margin_y_total_collapse_complex__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -49,6 +57,7 @@ fn block_margin_y_total_collapse_complex__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -56,6 +65,7 @@ fn block_margin_y_total_collapse_complex__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -65,6 +75,10 @@ fn block_margin_y_total_collapse_complex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -75,54 +89,338 @@ fn block_margin_y_total_collapse_complex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), -6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -134,6 +432,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -142,6 +441,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -150,6 +450,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(7f32), bottom: length(3f32) }, ..Default::default() @@ -158,6 +459,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-6f32), bottom: length(9f32) }, ..Default::default() @@ -167,6 +469,10 @@ fn block_margin_y_total_collapse_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -182,6 +488,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-5f32), bottom: length(-5f32) }, ..Default::default() @@ -190,6 +497,7 @@ fn block_margin_y_total_collapse_complex__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(-10f32), bottom: length(-10f32) }, ..Default::default() @@ -200,6 +508,10 @@ fn block_margin_y_total_collapse_complex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -210,52 +522,336 @@ fn block_margin_y_total_collapse_complex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 7f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), -6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node3, -10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs b/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs index 9fc1b9a2f..64f405d6b 100644 --- a/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs +++ b/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_overridden_by_available_space__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -34,6 +35,10 @@ fn block_overflow_scrollbars_overridden_by_available_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -47,42 +52,125 @@ fn block_overflow_scrollbars_overridden_by_available_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 11f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 11f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node0, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +183,7 @@ fn block_overflow_scrollbars_overridden_by_available_space__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -124,6 +213,10 @@ fn block_overflow_scrollbars_overridden_by_available_space__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -137,40 +230,123 @@ fn block_overflow_scrollbars_overridden_by_available_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 11f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 11f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node0, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs b/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs index f0ecff3b8..3b72e309c 100644 --- a/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs +++ b/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_overridden_by_max_size__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -38,36 +39,86 @@ fn block_overflow_scrollbars_overridden_by_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +131,7 @@ fn block_overflow_scrollbars_overridden_by_max_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -112,34 +164,84 @@ fn block_overflow_scrollbars_overridden_by_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs b/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs index 09a097fea..1f3448b44 100644 --- a/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs +++ b/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_overridden_by_size__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -38,36 +39,86 @@ fn block_overflow_scrollbars_overridden_by_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +131,7 @@ fn block_overflow_scrollbars_overridden_by_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -112,34 +164,84 @@ fn block_overflow_scrollbars_overridden_by_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs index 2d1a7873d..182d08737 100644 --- a/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_take_up_space_both_axis__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -38,36 +39,86 @@ fn block_overflow_scrollbars_take_up_space_both_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +131,7 @@ fn block_overflow_scrollbars_take_up_space_both_axis__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -112,34 +164,84 @@ fn block_overflow_scrollbars_take_up_space_both_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs b/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs index c91e17271..41ef4a7ae 100644 --- a/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs +++ b/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_take_up_space_cross_axis__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -38,36 +39,86 @@ fn block_overflow_scrollbars_take_up_space_cross_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +131,7 @@ fn block_overflow_scrollbars_take_up_space_cross_axis__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -112,34 +164,84 @@ fn block_overflow_scrollbars_take_up_space_cross_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs b/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs index 1111ccdac..2ccc780a1 100644 --- a/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs +++ b/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs @@ -7,6 +7,7 @@ fn block_overflow_scrollbars_take_up_space_main_axis__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -38,36 +39,86 @@ fn block_overflow_scrollbars_take_up_space_main_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +131,7 @@ fn block_overflow_scrollbars_take_up_space_main_axis__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), @@ -112,34 +164,84 @@ fn block_overflow_scrollbars_take_up_space_main_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_fixed_size.rs b/tests/generated/block/block_padding_border_fixed_size.rs index 9577d3f35..f3d9dff62 100644 --- a/tests/generated/block/block_padding_border_fixed_size.rs +++ b/tests/generated/block/block_padding_border_fixed_size.rs @@ -6,12 +6,14 @@ fn block_padding_border_fixed_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -20,6 +22,10 @@ fn block_padding_border_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -45,24 +51,125 @@ fn block_padding_border_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node1, 28f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn block_padding_border_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -81,6 +189,7 @@ fn block_padding_border_fixed_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -90,6 +199,10 @@ fn block_padding_border_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -115,22 +228,123 @@ fn block_padding_border_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node, 72f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_intrinsic_size.rs b/tests/generated/block/block_padding_border_intrinsic_size.rs index 86aa6f869..624f66044 100644 --- a/tests/generated/block/block_padding_border_intrinsic_size.rs +++ b/tests/generated/block/block_padding_border_intrinsic_size.rs @@ -6,6 +6,7 @@ fn block_padding_border_intrinsic_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn block_padding_border_intrinsic_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -23,6 +25,10 @@ fn block_padding_border_intrinsic_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(7f32), right: length(3f32), @@ -44,24 +50,125 @@ fn block_padding_border_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node, 72f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node, 34f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +180,7 @@ fn block_padding_border_intrinsic_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -83,6 +191,7 @@ fn block_padding_border_intrinsic_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -92,6 +201,10 @@ fn block_padding_border_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(7f32), right: length(3f32), @@ -113,22 +226,123 @@ fn block_padding_border_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node, 72f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node, 34f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_overrides_max_size.rs b/tests/generated/block/block_padding_border_overrides_max_size.rs index 3a28a33f0..22b404796 100644 --- a/tests/generated/block/block_padding_border_overrides_max_size.rs +++ b/tests/generated/block/block_padding_border_overrides_max_size.rs @@ -4,11 +4,20 @@ fn block_padding_border_overrides_max_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -32,7 +41,14 @@ fn block_padding_border_overrides_max_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -40,24 +56,125 @@ fn block_padding_border_overrides_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,21 @@ fn block_padding_border_overrides_max_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -100,6 +225,10 @@ fn block_padding_border_overrides_max_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -109,22 +238,123 @@ fn block_padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_overrides_min_size.rs b/tests/generated/block/block_padding_border_overrides_min_size.rs index 4e3c977bb..93f53cd3d 100644 --- a/tests/generated/block/block_padding_border_overrides_min_size.rs +++ b/tests/generated/block/block_padding_border_overrides_min_size.rs @@ -4,11 +4,20 @@ fn block_padding_border_overrides_min_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -32,7 +41,14 @@ fn block_padding_border_overrides_min_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -40,24 +56,125 @@ fn block_padding_border_overrides_min_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,21 @@ fn block_padding_border_overrides_min_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -100,6 +225,10 @@ fn block_padding_border_overrides_min_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -109,22 +238,123 @@ fn block_padding_border_overrides_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_overrides_size.rs b/tests/generated/block/block_padding_border_overrides_size.rs index 4f8a5bb3a..8cfe930c8 100644 --- a/tests/generated/block/block_padding_border_overrides_size.rs +++ b/tests/generated/block/block_padding_border_overrides_size.rs @@ -4,11 +4,20 @@ fn block_padding_border_overrides_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -32,7 +41,14 @@ fn block_padding_border_overrides_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -40,24 +56,125 @@ fn block_padding_border_overrides_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,21 @@ fn block_padding_border_overrides_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -100,6 +225,10 @@ fn block_padding_border_overrides_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -109,22 +238,123 @@ fn block_padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node00, 12f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00, 3f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_percentage_fixed_size.rs b/tests/generated/block/block_padding_border_percentage_fixed_size.rs index 09c2c3247..006a096ea 100644 --- a/tests/generated/block/block_padding_border_percentage_fixed_size.rs +++ b/tests/generated/block/block_padding_border_percentage_fixed_size.rs @@ -7,6 +7,7 @@ fn block_padding_border_percentage_fixed_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -15,6 +16,10 @@ fn block_padding_border_percentage_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -30,6 +35,10 @@ fn block_padding_border_percentage_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -43,24 +52,131 @@ fn block_padding_border_percentage_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 47f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 47f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +189,7 @@ fn block_padding_border_percentage_fixed_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +199,10 @@ fn block_padding_border_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -98,6 +219,10 @@ fn block_padding_border_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -111,22 +236,129 @@ fn block_padding_border_percentage_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 47f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 47f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs b/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs index 31ecd9b91..4af989fcc 100644 --- a/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs +++ b/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs @@ -7,6 +7,7 @@ fn block_padding_border_percentage_intrinsic_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -15,6 +16,10 @@ fn block_padding_border_percentage_intrinsic_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -28,7 +33,14 @@ fn block_padding_border_percentage_intrinsic_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -36,24 +48,131 @@ fn block_padding_border_percentage_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn block_padding_border_percentage_intrinsic_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -75,6 +195,10 @@ fn block_padding_border_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -91,6 +215,10 @@ fn block_padding_border_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -100,22 +228,129 @@ fn block_padding_border_percentage_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_fixed_size.rs b/tests/generated/block/block_padding_fixed_size.rs index 4e7ebee65..7e0ba077c 100644 --- a/tests/generated/block/block_padding_fixed_size.rs +++ b/tests/generated/block/block_padding_fixed_size.rs @@ -6,12 +6,14 @@ fn block_padding_fixed_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -20,6 +22,10 @@ fn block_padding_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -39,24 +45,125 @@ fn block_padding_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node0, 38f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 38f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node1, 38f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 38f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn block_padding_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -75,6 +183,7 @@ fn block_padding_fixed_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -84,6 +193,10 @@ fn block_padding_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,22 +216,123 @@ fn block_padding_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 58f32, "height of node {:?}. Expected {}. Actual {}", node, 58f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 58f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 58f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_intrinsic_size.rs b/tests/generated/block/block_padding_intrinsic_size.rs index c0ffbfe10..8e5453ae1 100644 --- a/tests/generated/block/block_padding_intrinsic_size.rs +++ b/tests/generated/block/block_padding_intrinsic_size.rs @@ -6,6 +6,7 @@ fn block_padding_intrinsic_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn block_padding_intrinsic_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -23,6 +25,10 @@ fn block_padding_intrinsic_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -38,24 +44,125 @@ fn block_padding_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 28f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +174,7 @@ fn block_padding_intrinsic_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -77,6 +185,7 @@ fn block_padding_intrinsic_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -86,6 +195,10 @@ fn block_padding_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -101,22 +214,123 @@ fn block_padding_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 28f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_percentage_fixed_size.rs b/tests/generated/block/block_padding_percentage_fixed_size.rs index 9becb8793..9f8956937 100644 --- a/tests/generated/block/block_padding_percentage_fixed_size.rs +++ b/tests/generated/block/block_padding_percentage_fixed_size.rs @@ -7,6 +7,7 @@ fn block_padding_percentage_fixed_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -15,6 +16,10 @@ fn block_padding_percentage_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -30,6 +35,10 @@ fn block_padding_percentage_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -43,24 +52,131 @@ fn block_padding_percentage_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 47f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 47f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +189,7 @@ fn block_padding_percentage_fixed_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +199,10 @@ fn block_padding_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -98,6 +219,10 @@ fn block_padding_percentage_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -111,22 +236,129 @@ fn block_padding_percentage_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + if layout.size.width != 47f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 47f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/block_padding_percentage_intrinsic_size.rs b/tests/generated/block/block_padding_percentage_intrinsic_size.rs index 59a859c18..25d8fbe2b 100644 --- a/tests/generated/block/block_padding_percentage_intrinsic_size.rs +++ b/tests/generated/block/block_padding_percentage_intrinsic_size.rs @@ -7,6 +7,7 @@ fn block_padding_percentage_intrinsic_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -15,6 +16,10 @@ fn block_padding_percentage_intrinsic_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -28,7 +33,14 @@ fn block_padding_percentage_intrinsic_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -36,24 +48,131 @@ fn block_padding_percentage_intrinsic_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn block_padding_percentage_intrinsic_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -75,6 +195,10 @@ fn block_padding_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: percent(0.04f32), right: percent(0.02f32), @@ -91,6 +215,10 @@ fn block_padding_percentage_intrinsic_size__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -100,22 +228,129 @@ fn block_padding_percentage_intrinsic_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/block/mod.rs b/tests/generated/block/mod.rs index 621d0358a..22abfba5e 100644 --- a/tests/generated/block/mod.rs +++ b/tests/generated/block/mod.rs @@ -50,6 +50,10 @@ mod block_absolute_minmax_bottom_right_min_max_preferred; mod block_absolute_minmax_top_left_bottom_right_max; mod block_absolute_minmax_top_left_bottom_right_min_max; mod block_absolute_no_styles; +mod block_absolute_overflow_clip; +mod block_absolute_overflow_hidden; +mod block_absolute_overflow_scroll; +mod block_absolute_overflow_visible; mod block_absolute_padding_border_overrides_max_size; mod block_absolute_padding_border_overrides_size; mod block_absolute_resolved_insets; @@ -76,6 +80,10 @@ mod block_display_none_with_child; mod block_display_none_with_inset; mod block_display_none_with_margin; mod block_display_none_with_position_absolute; +mod block_inflow_overflow_clip; +mod block_inflow_overflow_hidden; +mod block_inflow_overflow_scroll; +mod block_inflow_overflow_visible; mod block_inset_fixed; mod block_inset_percentage; mod block_intrinsic_width; diff --git a/tests/generated/blockflex/blockflex_block_in_flex_column.rs b/tests/generated/blockflex/blockflex_block_in_flex_column.rs index 0db3c8eb1..4c97feaa0 100644 --- a/tests/generated/blockflex/blockflex_block_in_flex_column.rs +++ b/tests/generated/blockflex/blockflex_block_in_flex_column.rs @@ -4,11 +4,17 @@ fn blockflex_block_in_flex_column__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -18,6 +24,10 @@ fn blockflex_block_in_flex_column__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,24 +41,125 @@ fn blockflex_block_in_flex_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +172,7 @@ fn blockflex_block_in_flex_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -68,6 +180,7 @@ fn blockflex_block_in_flex_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -78,6 +191,10 @@ fn blockflex_block_in_flex_column__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(50f32), @@ -91,22 +208,123 @@ fn blockflex_block_in_flex_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_block_in_flex_row.rs b/tests/generated/blockflex/blockflex_block_in_flex_row.rs index 84f182983..280f5d253 100644 --- a/tests/generated/blockflex/blockflex_block_in_flex_row.rs +++ b/tests/generated/blockflex/blockflex_block_in_flex_row.rs @@ -4,11 +4,17 @@ fn blockflex_block_in_flex_row__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -17,6 +23,10 @@ fn blockflex_block_in_flex_row__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(50f32), @@ -30,24 +40,125 @@ fn blockflex_block_in_flex_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +171,7 @@ fn blockflex_block_in_flex_row__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -67,6 +179,7 @@ fn blockflex_block_in_flex_row__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -76,6 +189,10 @@ fn blockflex_block_in_flex_row__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(50f32), @@ -89,22 +206,123 @@ fn blockflex_block_in_flex_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_flex_in_block.rs b/tests/generated/blockflex/blockflex_flex_in_block.rs index df3926aef..782008e30 100644 --- a/tests/generated/blockflex/blockflex_flex_in_block.rs +++ b/tests/generated/blockflex/blockflex_flex_in_block.rs @@ -6,6 +6,7 @@ fn blockflex_flex_in_block__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,13 +16,21 @@ fn blockflex_flex_in_block__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +42,10 @@ fn blockflex_flex_in_block__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -43,30 +56,170 @@ fn blockflex_flex_in_block__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +231,7 @@ fn blockflex_flex_in_block__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +244,10 @@ fn blockflex_flex_in_block__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -99,6 +257,7 @@ fn blockflex_flex_in_block__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -111,6 +270,10 @@ fn blockflex_flex_in_block__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -121,28 +284,168 @@ fn blockflex_flex_in_block__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs b/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs index 6b46ace17..95182b974 100644 --- a/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs +++ b/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs @@ -7,6 +7,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs b/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs index 1ea843bc0..ea3972826 100644 --- a/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs +++ b/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs @@ -6,6 +6,7 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs b/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs index 5b6875358..218f95cab 100644 --- a/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs +++ b/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs @@ -6,6 +6,7 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockflex/blockflex_overflow_hidden.rs b/tests/generated/blockflex/blockflex_overflow_hidden.rs index cbe5d151b..b1070a153 100644 --- a/tests/generated/blockflex/blockflex_overflow_hidden.rs +++ b/tests/generated/blockflex/blockflex_overflow_hidden.rs @@ -21,7 +21,15 @@ fn blockflex_overflow_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, flex_grow: 1f32, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -29,6 +37,10 @@ fn blockflex_overflow_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(50f32), @@ -42,42 +54,125 @@ fn blockflex_overflow_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 40f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 40f32, - layout.scroll_width() - ); + if layout.scroll_width() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 40f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -107,6 +202,10 @@ fn blockflex_overflow_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -118,6 +217,10 @@ fn blockflex_overflow_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(50f32), @@ -131,40 +234,123 @@ fn blockflex_overflow_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 40f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 40f32, - layout.scroll_width() - ); + if layout.scroll_width() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 40f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs index 927e4e833..4fc3fcfae 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_auto__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto()], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_auto__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_auto__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_auto__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_auto__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto()], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_auto__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs index 98cbf7d90..b98f527bc 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(50f32))], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(50f32))], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs index 74ca2179c..78a9c23ef 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs index 70bb22308..c09720576 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(10f32))], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fit_content(length(10f32))], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs index 36a2853ce..03183378f 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_larger__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(50f32)], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_larger__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_larger__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_larger__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(50f32)], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_larger__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs index 57c450047..76f3b7121 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_middle__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(30f32)], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_middle__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_middle__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_middle__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_middle__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(30f32)], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_middle__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs index e898da266..9810b2553 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fixed_smaller__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(10f32)], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fixed_smaller__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fixed_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fixed_smaller__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fixed_smaller__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![length(10f32)], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fixed_smaller__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs index b2dbb149c..dbcb69920 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_fr__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fr(1f32)], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_fr__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_fr__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_fr__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_fr__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![fr(1f32)], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_fr__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs index 2ca4879fb..460b5758d 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_max_content__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs b/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs index 89d95c721..813f0a6d1 100644 --- a/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs +++ b/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs @@ -6,16 +6,32 @@ fn blockgrid_block_in_grid_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -26,24 +42,125 @@ fn blockgrid_block_in_grid_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +174,10 @@ fn blockgrid_block_in_grid_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -66,6 +187,7 @@ fn blockgrid_block_in_grid_min_content__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -74,6 +196,10 @@ fn blockgrid_block_in_grid_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -84,22 +210,123 @@ fn blockgrid_block_in_grid_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_grid_in_block.rs b/tests/generated/blockgrid/blockgrid_grid_in_block.rs index 24cb8fe01..a0177c121 100644 --- a/tests/generated/blockgrid/blockgrid_grid_in_block.rs +++ b/tests/generated/blockgrid/blockgrid_grid_in_block.rs @@ -6,6 +6,7 @@ fn blockgrid_grid_in_block__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,13 +16,21 @@ fn blockgrid_grid_in_block__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +42,10 @@ fn blockgrid_grid_in_block__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -43,30 +56,170 @@ fn blockgrid_grid_in_block__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +231,7 @@ fn blockgrid_grid_in_block__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +244,10 @@ fn blockgrid_grid_in_block__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -99,6 +257,7 @@ fn blockgrid_grid_in_block__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -111,6 +270,10 @@ fn blockgrid_grid_in_block__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -121,28 +284,168 @@ fn blockgrid_grid_in_block__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs b/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs index 507572734..81474b74e 100644 --- a/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs +++ b/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs @@ -7,6 +7,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -22,6 +24,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -31,6 +34,10 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -41,30 +48,164 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() }) @@ -94,6 +237,7 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -104,6 +248,10 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -114,28 +262,162 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs b/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs index 875565562..a6c6bd638 100644 --- a/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs +++ b/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs @@ -6,6 +6,7 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -34,6 +43,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -99,6 +263,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -110,6 +278,10 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs b/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs index 535be2a6c..5487eaf87 100644 --- a/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs +++ b/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs @@ -6,6 +6,7 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -14,6 +15,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -34,6 +43,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -44,30 +57,176 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +238,7 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +248,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -99,6 +263,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }, @@ -110,6 +278,10 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -120,28 +292,174 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs index c515643da..664840138 100644 --- a/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__border_box let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -21,6 +22,10 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__border_box .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__border_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__content_bo .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -73,6 +153,10 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__content_bo taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset__content_bo println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_height.rs b/tests/generated/flex/absolute_aspect_ratio_fill_height.rs index 1537ce196..f1d478e6c 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_height.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_height.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn absolute_aspect_ratio_fill_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn absolute_aspect_ratio_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn absolute_aspect_ratio_fill_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn absolute_aspect_ratio_fill_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn absolute_aspect_ratio_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs b/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs index 83a71b6fe..9c62a8dff 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_height_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -21,6 +22,10 @@ fn absolute_aspect_ratio_fill_height_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn absolute_aspect_ratio_fill_height_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn absolute_aspect_ratio_fill_height_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -73,6 +153,10 @@ fn absolute_aspect_ratio_fill_height_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn absolute_aspect_ratio_fill_height_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs b/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs index 22a1acdd7..2847e2e41 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs @@ -4,24 +4,31 @@ fn absolute_aspect_ratio_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +42,86 @@ fn absolute_aspect_ratio_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 73f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 73f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,19 +130,22 @@ fn absolute_aspect_ratio_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy @@ -75,6 +153,10 @@ fn absolute_aspect_ratio_fill_max_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +170,84 @@ fn absolute_aspect_ratio_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 73f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 73f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs b/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs index 233dc0966..e70ae5415 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs @@ -4,24 +4,31 @@ fn absolute_aspect_ratio_fill_max_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +42,86 @@ fn absolute_aspect_ratio_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,19 +130,22 @@ fn absolute_aspect_ratio_fill_max_width__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); + let node0_text = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; let node0 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() }, - crate::TestNodeContext::ahem_text( - "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", - crate::WritingMode::Horizontal, - ), + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy @@ -75,6 +153,10 @@ fn absolute_aspect_ratio_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +170,84 @@ fn absolute_aspect_ratio_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs b/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs index 729c9ab16..d1f423fc2 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_min_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() @@ -16,6 +17,10 @@ fn absolute_aspect_ratio_fill_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn absolute_aspect_ratio_fill_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn absolute_aspect_ratio_fill_min_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(3f32), ..Default::default() @@ -63,6 +137,10 @@ fn absolute_aspect_ratio_fill_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn absolute_aspect_ratio_fill_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 17f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs b/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs index f57c9cb4f..b998d0b4f 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_min_width__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() @@ -16,6 +17,10 @@ fn absolute_aspect_ratio_fill_min_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn absolute_aspect_ratio_fill_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn absolute_aspect_ratio_fill_min_width__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(0.5f32), ..Default::default() @@ -63,6 +137,10 @@ fn absolute_aspect_ratio_fill_min_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn absolute_aspect_ratio_fill_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_width.rs b/tests/generated/flex/absolute_aspect_ratio_fill_width.rs index 77e543bd8..ead2d206a 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_width.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_width.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_width__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn absolute_aspect_ratio_fill_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn absolute_aspect_ratio_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn absolute_aspect_ratio_fill_width__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn absolute_aspect_ratio_fill_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn absolute_aspect_ratio_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs b/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs index cfc008610..db778d98a 100644 --- a/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs +++ b/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_fill_width_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn absolute_aspect_ratio_fill_width_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn absolute_aspect_ratio_fill_width_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn absolute_aspect_ratio_fill_width_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -63,6 +137,10 @@ fn absolute_aspect_ratio_fill_width_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn absolute_aspect_ratio_fill_width_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs b/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs index 279d8c6b6..6fe83107a 100644 --- a/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs +++ b/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_height_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -17,6 +18,10 @@ fn absolute_aspect_ratio_height_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -30,18 +35,86 @@ fn absolute_aspect_ratio_height_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn absolute_aspect_ratio_height_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -65,6 +139,10 @@ fn absolute_aspect_ratio_height_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -78,16 +156,84 @@ fn absolute_aspect_ratio_height_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs b/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs index 345a5cb77..25b537ac2 100644 --- a/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs +++ b/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs @@ -7,6 +7,7 @@ fn absolute_aspect_ratio_width_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn absolute_aspect_ratio_width_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn absolute_aspect_ratio_width_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn absolute_aspect_ratio_width_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn absolute_aspect_ratio_width_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn absolute_aspect_ratio_width_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_child_with_cross_margin.rs b/tests/generated/flex/absolute_child_with_cross_margin.rs index a8a728872..9d09e3d4a 100644 --- a/tests/generated/flex/absolute_child_with_cross_margin.rs +++ b/tests/generated/flex/absolute_child_with_cross_margin.rs @@ -6,6 +6,7 @@ fn absolute_child_with_cross_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(28f32), @@ -18,6 +19,10 @@ fn absolute_child_with_cross_margin__border_box() { .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_grow: 0f32, flex_shrink: 1f32, @@ -33,6 +38,7 @@ fn absolute_child_with_cross_margin__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -44,6 +50,10 @@ fn absolute_child_with_cross_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(311f32), @@ -62,30 +72,164 @@ fn absolute_child_with_cross_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node, 311f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node, 27f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 311f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 311f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node0, 27f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node1, 311f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node1, 4f32, location.y); + if layout.size.width != 311f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 311f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node2, 25f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node2, 27f32, size.height); - assert_eq!(location.x, 286f32, "x of node {:?}. Expected {}. Actual {}", node2, 286f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 286f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 286f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +241,7 @@ fn absolute_child_with_cross_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(28f32), @@ -110,6 +255,10 @@ fn absolute_child_with_cross_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_grow: 0f32, flex_shrink: 1f32, @@ -126,6 +275,7 @@ fn absolute_child_with_cross_margin__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -138,6 +288,10 @@ fn absolute_child_with_cross_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(311f32), @@ -156,28 +310,162 @@ fn absolute_child_with_cross_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node, 311f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node, 27f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 311f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 311f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node0, 27f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node1, 311f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node1, 4f32, location.y); + if layout.size.width != 311f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 311f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 15f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node2, 25f32, size.width); - assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node2, 27f32, size.height); - assert_eq!(location.x, 286f32, "x of node {:?}. Expected {}. Actual {}", node2, 286f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 27f32, layout.size.height); + } + if layout.location.x != 286f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 286f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_child_with_main_margin.rs b/tests/generated/flex/absolute_child_with_main_margin.rs index fa235b01d..774209599 100644 --- a/tests/generated/flex/absolute_child_with_main_margin.rs +++ b/tests/generated/flex/absolute_child_with_main_margin.rs @@ -7,6 +7,7 @@ fn absolute_child_with_main_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -18,6 +19,10 @@ fn absolute_child_with_main_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -31,18 +36,86 @@ fn absolute_child_with_main_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_child_with_main_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(9f32), height: taffy::style::Dimension::from_length(9f32), @@ -67,6 +141,10 @@ fn absolute_child_with_main_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(37f32), @@ -80,16 +158,84 @@ fn absolute_child_with_main_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 37f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); - assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 9f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_child_with_max_height.rs b/tests/generated/flex/absolute_child_with_max_height.rs index 7618dd50a..3ab0cfa2b 100644 --- a/tests/generated/flex/absolute_child_with_max_height.rs +++ b/tests/generated/flex/absolute_child_with_max_height.rs @@ -6,6 +6,7 @@ fn absolute_child_with_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(30f32), @@ -18,6 +19,10 @@ fn absolute_child_with_max_height__border_box() { taffy::style::Style { position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -29,6 +34,10 @@ fn absolute_child_with_max_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -42,24 +51,131 @@ fn absolute_child_with_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node00, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +187,7 @@ fn absolute_child_with_max_height__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(30f32), @@ -84,6 +201,10 @@ fn absolute_child_with_max_height__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -96,6 +217,10 @@ fn absolute_child_with_max_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -109,22 +234,129 @@ fn absolute_child_with_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node00, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs b/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs index 86d1792fe..f58a97f0b 100644 --- a/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs +++ b/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs @@ -6,6 +6,7 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(150f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -17,6 +18,10 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__border_box() { taffy::style::Style { position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -28,6 +33,10 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -41,24 +50,137 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -70,6 +192,7 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(150f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -82,6 +205,10 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) }, ..Default::default() @@ -94,6 +221,10 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -107,22 +238,135 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs index dc9722cba..6a384ac31 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_center__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -17,6 +18,10 @@ fn absolute_layout_align_items_and_justify_content_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -32,18 +37,86 @@ fn absolute_layout_align_items_and_justify_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn absolute_layout_align_items_and_justify_content_center__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -67,6 +141,10 @@ fn absolute_layout_align_items_and_justify_content_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -82,16 +160,84 @@ fn absolute_layout_align_items_and_justify_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs index a5a9ed8b0..4eeb71a33 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__b let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -18,6 +19,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__b let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -33,18 +38,86 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__b println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__c .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -69,6 +143,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__c .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -84,16 +162,84 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position__c println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs index e33415900..fa13ee9c1 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__bor let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -18,6 +19,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__bor let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -33,18 +38,86 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__bor println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__con .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -69,6 +143,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__con .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -84,16 +162,84 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position__con println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs index 45086afc6..5397736cc 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__bo let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -18,6 +19,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__bo let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -33,18 +38,86 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__bo println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__co .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -69,6 +143,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__co .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -84,16 +162,84 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position__co println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs index 3766236ae..bd7012a47 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__bord let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -18,6 +19,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__bord let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -33,18 +38,86 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__bord println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__cont .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -69,6 +143,10 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__cont .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -84,16 +162,84 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position__cont println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs b/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs index b814da5db..86abe08b7 100644 --- a/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs +++ b/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_and_justify_content_flex_end__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -17,6 +18,10 @@ fn absolute_layout_align_items_and_justify_content_flex_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -32,18 +37,86 @@ fn absolute_layout_align_items_and_justify_content_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn absolute_layout_align_items_and_justify_content_flex_end__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -67,6 +141,10 @@ fn absolute_layout_align_items_and_justify_content_flex_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -82,16 +160,84 @@ fn absolute_layout_align_items_and_justify_content_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_center.rs b/tests/generated/flex/absolute_layout_align_items_center.rs index fa9ff983a..dff7ca2ba 100644 --- a/tests/generated/flex/absolute_layout_align_items_center.rs +++ b/tests/generated/flex/absolute_layout_align_items_center.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_center__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -17,6 +18,10 @@ fn absolute_layout_align_items_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), @@ -31,18 +36,86 @@ fn absolute_layout_align_items_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_align_items_center__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -66,6 +140,10 @@ fn absolute_layout_align_items_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), @@ -80,16 +158,84 @@ fn absolute_layout_align_items_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs b/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs index 1cb6f78b1..826c43707 100644 --- a/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs +++ b/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs @@ -7,6 +7,7 @@ fn absolute_layout_align_items_center_on_child_only__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -18,6 +19,10 @@ fn absolute_layout_align_items_center_on_child_only__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_align_items_center_on_child_only__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_align_items_center_on_child_only__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -67,6 +141,10 @@ fn absolute_layout_align_items_center_on_child_only__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_align_items_center_on_child_only__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_child_order.rs b/tests/generated/flex/absolute_layout_child_order.rs index 24ef2803b..c12a630d8 100644 --- a/tests/generated/flex/absolute_layout_child_order.rs +++ b/tests/generated/flex/absolute_layout_child_order.rs @@ -6,6 +6,7 @@ fn absolute_layout_child_order__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -16,6 +17,7 @@ fn absolute_layout_child_order__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -25,6 +27,7 @@ fn absolute_layout_child_order__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -35,6 +38,10 @@ fn absolute_layout_child_order__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -50,30 +57,164 @@ fn absolute_layout_child_order__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node1, 25f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node2, 55f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -85,6 +226,7 @@ fn absolute_layout_child_order__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -96,6 +238,7 @@ fn absolute_layout_child_order__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -106,6 +249,7 @@ fn absolute_layout_child_order__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -117,6 +261,10 @@ fn absolute_layout_child_order__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -132,28 +280,162 @@ fn absolute_layout_child_order__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node1, 25f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node2, 55f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs b/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs index 8eceda733..6e4dafd56 100644 --- a/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs +++ b/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs @@ -7,6 +7,7 @@ fn absolute_layout_in_wrap_reverse_column_container__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -19,6 +20,10 @@ fn absolute_layout_in_wrap_reverse_column_container__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn absolute_layout_in_wrap_reverse_column_container__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn absolute_layout_in_wrap_reverse_column_container__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -69,6 +143,10 @@ fn absolute_layout_in_wrap_reverse_column_container__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn absolute_layout_in_wrap_reverse_column_container__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs index da1126e0c..2ffdc2514 100644 --- a/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs +++ b/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -7,6 +7,7 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -20,6 +21,10 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -71,6 +145,10 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs b/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs index fead69dee..fbeea02a7 100644 --- a/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs +++ b/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs @@ -7,6 +7,7 @@ fn absolute_layout_in_wrap_reverse_row_container__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn absolute_layout_in_wrap_reverse_row_container__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_in_wrap_reverse_row_container__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_in_wrap_reverse_row_container__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -67,6 +141,10 @@ fn absolute_layout_in_wrap_reverse_row_container__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_in_wrap_reverse_row_container__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs index 1a191c65d..9e71f5a71 100644 --- a/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs +++ b/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -7,6 +7,7 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -19,6 +20,10 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -69,6 +143,10 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_justify_content_center.rs b/tests/generated/flex/absolute_layout_justify_content_center.rs index 1f221c425..563439611 100644 --- a/tests/generated/flex/absolute_layout_justify_content_center.rs +++ b/tests/generated/flex/absolute_layout_justify_content_center.rs @@ -7,6 +7,7 @@ fn absolute_layout_justify_content_center__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -17,6 +18,10 @@ fn absolute_layout_justify_content_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), @@ -31,18 +36,86 @@ fn absolute_layout_justify_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_justify_content_center__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(40f32), @@ -66,6 +140,10 @@ fn absolute_layout_justify_content_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), @@ -80,16 +158,84 @@ fn absolute_layout_justify_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_no_size.rs b/tests/generated/flex/absolute_layout_no_size.rs index a2739be35..a52282415 100644 --- a/tests/generated/flex/absolute_layout_no_size.rs +++ b/tests/generated/flex/absolute_layout_no_size.rs @@ -5,11 +5,19 @@ fn absolute_layout_no_size__border_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }) + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -23,18 +31,86 @@ fn absolute_layout_no_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,6 +123,7 @@ fn absolute_layout_no_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -54,6 +131,10 @@ fn absolute_layout_no_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -67,16 +148,84 @@ fn absolute_layout_no_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs index 0a51b9b00..1f58ce69d 100644 --- a/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -7,6 +7,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -18,6 +19,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -29,6 +31,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.1f32), bottom: percent(0.1f32) }, ..Default::default() @@ -37,6 +40,10 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -50,30 +57,170 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +233,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -98,6 +246,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -110,6 +259,7 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.1f32), bottom: percent(0.1f32) }, ..Default::default() @@ -119,6 +269,10 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -132,28 +286,168 @@ fn absolute_layout_percentage_bottom_based_on_parent_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_percentage_height.rs b/tests/generated/flex/absolute_layout_percentage_height.rs index 0be60f7c5..678e764aa 100644 --- a/tests/generated/flex/absolute_layout_percentage_height.rs +++ b/tests/generated/flex/absolute_layout_percentage_height.rs @@ -7,6 +7,7 @@ fn absolute_layout_percentage_height__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -18,6 +19,10 @@ fn absolute_layout_percentage_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_percentage_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_percentage_height__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -67,6 +141,10 @@ fn absolute_layout_percentage_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_percentage_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs b/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs index 1cb45511b..b1045daeb 100644 --- a/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs +++ b/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs @@ -7,6 +7,7 @@ fn absolute_layout_row_width_height_end_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -18,6 +19,10 @@ fn absolute_layout_row_width_height_end_bottom__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_row_width_height_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_row_width_height_end_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -67,6 +141,10 @@ fn absolute_layout_row_width_height_end_bottom__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_row_width_height_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_start_top_end_bottom.rs b/tests/generated/flex/absolute_layout_start_top_end_bottom.rs index 800ccf4b4..c7d9467d3 100644 --- a/tests/generated/flex/absolute_layout_start_top_end_bottom.rs +++ b/tests/generated/flex/absolute_layout_start_top_end_bottom.rs @@ -7,6 +7,7 @@ fn absolute_layout_start_top_end_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -19,6 +20,10 @@ fn absolute_layout_start_top_end_bottom__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn absolute_layout_start_top_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn absolute_layout_start_top_end_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -69,6 +143,10 @@ fn absolute_layout_start_top_end_bottom__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn absolute_layout_start_top_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_width_height_end_bottom.rs b/tests/generated/flex/absolute_layout_width_height_end_bottom.rs index 25a078662..d55f4fb1d 100644 --- a/tests/generated/flex/absolute_layout_width_height_end_bottom.rs +++ b/tests/generated/flex/absolute_layout_width_height_end_bottom.rs @@ -7,6 +7,7 @@ fn absolute_layout_width_height_end_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -18,6 +19,10 @@ fn absolute_layout_width_height_end_bottom__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_width_height_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_width_height_end_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -67,6 +141,10 @@ fn absolute_layout_width_height_end_bottom__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_width_height_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_width_height_start_top.rs b/tests/generated/flex/absolute_layout_width_height_start_top.rs index 55c6ffb33..119baba5f 100644 --- a/tests/generated/flex/absolute_layout_width_height_start_top.rs +++ b/tests/generated/flex/absolute_layout_width_height_start_top.rs @@ -7,6 +7,7 @@ fn absolute_layout_width_height_start_top__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -18,6 +19,10 @@ fn absolute_layout_width_height_start_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn absolute_layout_width_height_start_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn absolute_layout_width_height_start_top__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -67,6 +141,10 @@ fn absolute_layout_width_height_start_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn absolute_layout_width_height_start_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs index ad3da7259..99767266d 100644 --- a/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs +++ b/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs @@ -7,6 +7,7 @@ fn absolute_layout_width_height_start_top_end_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -23,6 +24,10 @@ fn absolute_layout_width_height_start_top_end_bottom__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -36,18 +41,86 @@ fn absolute_layout_width_height_start_top_end_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +133,7 @@ fn absolute_layout_width_height_start_top_end_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -77,6 +151,10 @@ fn absolute_layout_width_height_start_top_end_bottom__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -90,16 +168,84 @@ fn absolute_layout_width_height_start_top_end_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_layout_within_border.rs b/tests/generated/flex/absolute_layout_within_border.rs index a18615067..22885853b 100644 --- a/tests/generated/flex/absolute_layout_within_border.rs +++ b/tests/generated/flex/absolute_layout_within_border.rs @@ -7,6 +7,7 @@ fn absolute_layout_within_border__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,7 @@ fn absolute_layout_within_border__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -29,6 +31,7 @@ fn absolute_layout_within_border__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -46,6 +49,7 @@ fn absolute_layout_within_border__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -63,6 +67,10 @@ fn absolute_layout_within_border__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,36 +96,203 @@ fn absolute_layout_within_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +305,7 @@ fn absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -142,6 +318,7 @@ fn absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -154,6 +331,7 @@ fn absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -172,6 +350,7 @@ fn absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -190,6 +369,10 @@ fn absolute_layout_within_border__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -215,34 +398,201 @@ fn absolute_layout_within_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node3, 70f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_margin_bottom_left.rs b/tests/generated/flex/absolute_margin_bottom_left.rs index cf0c4be64..b8501cd0d 100644 --- a/tests/generated/flex/absolute_margin_bottom_left.rs +++ b/tests/generated/flex/absolute_margin_bottom_left.rs @@ -7,6 +7,7 @@ fn absolute_margin_bottom_left__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -19,6 +20,10 @@ fn absolute_margin_bottom_left__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn absolute_margin_bottom_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +130,7 @@ fn absolute_margin_bottom_left__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -70,6 +144,10 @@ fn absolute_margin_bottom_left__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn absolute_margin_bottom_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_minmax_bottom_right_max.rs b/tests/generated/flex/absolute_minmax_bottom_right_max.rs index 251951d12..d31319f1b 100644 --- a/tests/generated/flex/absolute_minmax_bottom_right_max.rs +++ b/tests/generated/flex/absolute_minmax_bottom_right_max.rs @@ -7,6 +7,7 @@ fn absolute_minmax_bottom_right_max__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -22,6 +23,10 @@ fn absolute_minmax_bottom_right_max__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -35,18 +40,86 @@ fn absolute_minmax_bottom_right_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn absolute_minmax_bottom_right_max__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -75,6 +149,10 @@ fn absolute_minmax_bottom_right_max__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,16 +166,84 @@ fn absolute_minmax_bottom_right_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs b/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs index 5bf48fc02..30e5ada8e 100644 --- a/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs +++ b/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs @@ -7,6 +7,7 @@ fn absolute_minmax_bottom_right_min_max__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -22,6 +23,10 @@ fn absolute_minmax_bottom_right_min_max__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -35,18 +40,86 @@ fn absolute_minmax_bottom_right_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn absolute_minmax_bottom_right_min_max__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -75,6 +149,10 @@ fn absolute_minmax_bottom_right_min_max__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,16 +166,84 @@ fn absolute_minmax_bottom_right_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs b/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs index 650e08728..dcced8151 100644 --- a/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs +++ b/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs @@ -7,6 +7,7 @@ fn absolute_minmax_bottom_right_min_max_preferred__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -26,6 +27,10 @@ fn absolute_minmax_bottom_right_min_max_preferred__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -39,18 +44,86 @@ fn absolute_minmax_bottom_right_min_max_preferred__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +136,7 @@ fn absolute_minmax_bottom_right_min_max_preferred__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -83,6 +157,10 @@ fn absolute_minmax_bottom_right_min_max_preferred__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -96,16 +174,84 @@ fn absolute_minmax_bottom_right_min_max_preferred__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs b/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs index 8f720c317..0278adeb9 100644 --- a/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs +++ b/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs @@ -7,6 +7,7 @@ fn absolute_minmax_top_left_bottom_right_max__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(30f32), @@ -23,6 +24,10 @@ fn absolute_minmax_top_left_bottom_right_max__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -36,18 +41,86 @@ fn absolute_minmax_top_left_bottom_right_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +133,7 @@ fn absolute_minmax_top_left_bottom_right_max__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(30f32), @@ -77,6 +151,10 @@ fn absolute_minmax_top_left_bottom_right_max__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -90,16 +168,84 @@ fn absolute_minmax_top_left_bottom_right_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs b/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs index 7bb8cc287..9672e5399 100644 --- a/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs +++ b/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs @@ -7,6 +7,7 @@ fn absolute_minmax_top_left_bottom_right_min_max__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -27,6 +28,10 @@ fn absolute_minmax_top_left_bottom_right_min_max__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -40,18 +45,86 @@ fn absolute_minmax_top_left_bottom_right_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +137,7 @@ fn absolute_minmax_top_left_bottom_right_min_max__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -85,6 +159,10 @@ fn absolute_minmax_top_left_bottom_right_min_max__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -98,16 +176,84 @@ fn absolute_minmax_top_left_bottom_right_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_padding_border_overrides_max_size.rs b/tests/generated/flex/absolute_padding_border_overrides_max_size.rs index 64865053d..376686af7 100644 --- a/tests/generated/flex/absolute_padding_border_overrides_max_size.rs +++ b/tests/generated/flex/absolute_padding_border_overrides_max_size.rs @@ -7,6 +7,7 @@ fn absolute_padding_border_overrides_max_size__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -26,23 +27,102 @@ fn absolute_padding_border_overrides_max_size__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +135,7 @@ fn absolute_padding_border_overrides_max_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -76,7 +157,14 @@ fn absolute_padding_border_overrides_max_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -84,16 +172,84 @@ fn absolute_padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_padding_border_overrides_size.rs b/tests/generated/flex/absolute_padding_border_overrides_size.rs index 772ed658a..96cfed441 100644 --- a/tests/generated/flex/absolute_padding_border_overrides_size.rs +++ b/tests/generated/flex/absolute_padding_border_overrides_size.rs @@ -7,6 +7,7 @@ fn absolute_padding_border_overrides_size__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -26,23 +27,102 @@ fn absolute_padding_border_overrides_size__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 22f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 14f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +135,7 @@ fn absolute_padding_border_overrides_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -76,7 +157,14 @@ fn absolute_padding_border_overrides_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -84,16 +172,84 @@ fn absolute_padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 34f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 34f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 26f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/absolute_resolved_insets.rs b/tests/generated/flex/absolute_resolved_insets.rs index ce7ba0e6f..8a7e8b50d 100644 --- a/tests/generated/flex/absolute_resolved_insets.rs +++ b/tests/generated/flex/absolute_resolved_insets.rs @@ -7,6 +7,7 @@ fn absolute_resolved_insets__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -19,6 +20,7 @@ fn absolute_resolved_insets__border_box() { let node01 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -26,6 +28,7 @@ fn absolute_resolved_insets__border_box() { let node02 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -33,6 +36,7 @@ fn absolute_resolved_insets__border_box() { let node03 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -40,6 +44,7 @@ fn absolute_resolved_insets__border_box() { let node04 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -47,6 +52,7 @@ fn absolute_resolved_insets__border_box() { let node05 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -59,6 +65,10 @@ fn absolute_resolved_insets__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -83,6 +93,7 @@ fn absolute_resolved_insets__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -95,6 +106,7 @@ fn absolute_resolved_insets__border_box() { let node11 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -102,6 +114,7 @@ fn absolute_resolved_insets__border_box() { let node12 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -109,6 +122,7 @@ fn absolute_resolved_insets__border_box() { let node13 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -116,6 +130,7 @@ fn absolute_resolved_insets__border_box() { let node14 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -123,6 +138,7 @@ fn absolute_resolved_insets__border_box() { let node15 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -161,119 +177,633 @@ fn absolute_resolved_insets__border_box() { &[node10, node11, node12, node13, node14, node15], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node00, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node00, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node02, 180f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node02, 180f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node05, 160f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node05, 160f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node10, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node10, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 165f32, "x of node {:?}. Expected {}. Actual {}", node12, 165f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node12, 165f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 165f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node15, 145f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node15, 145f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -286,6 +816,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -299,6 +830,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -307,6 +839,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -315,6 +848,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -323,6 +857,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -331,6 +866,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -344,6 +880,10 @@ fn absolute_resolved_insets__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -369,6 +909,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -382,6 +923,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -390,6 +932,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -398,6 +941,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -406,6 +950,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -414,6 +959,7 @@ fn absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -455,7 +1001,14 @@ fn absolute_resolved_insets__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -463,112 +1016,615 @@ fn absolute_resolved_insets__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 540f32, "width of node {:?}. Expected {}. Actual {}", node, 540f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 540f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 540f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 270f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node0, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node0, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node00, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node00, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node02, 250f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node02, 250f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 230f32, "width of node {:?}. Expected {}. Actual {}", node05, 230f32, size.width); - assert_eq!(size.height, 230f32, "height of node {:?}. Expected {}. Actual {}", node05, 230f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 230f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 230f32, layout.size.width); + } + if layout.size.height != 230f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 230f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node1, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node1, 270f32, size.height); - assert_eq!(location.x, 270f32, "x of node {:?}. Expected {}. Actual {}", node1, 270f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 270f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node10, 35f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node10, 35f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 235f32, "x of node {:?}. Expected {}. Actual {}", node12, 235f32, location.x); - assert_eq!(location.y, 235f32, "y of node {:?}. Expected {}. Actual {}", node12, 235f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 235f32, layout.location.x); + } + if layout.location.y != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 235f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 215f32, "width of node {:?}. Expected {}. Actual {}", node15, 215f32, size.width); - assert_eq!(size.height, 215f32, "height of node {:?}. Expected {}. Actual {}", node15, 215f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 215f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 215f32, layout.size.width); + } + if layout.size.height != 215f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 215f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline.rs b/tests/generated/flex/align_baseline.rs index 6546eb862..0c45a45d1 100644 --- a/tests/generated/flex/align_baseline.rs +++ b/tests/generated/flex/align_baseline.rs @@ -6,6 +6,7 @@ fn align_baseline__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -25,6 +27,10 @@ fn align_baseline__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,24 +45,125 @@ fn align_baseline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn align_baseline__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -78,6 +186,7 @@ fn align_baseline__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +198,10 @@ fn align_baseline__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -103,22 +216,123 @@ fn align_baseline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child.rs b/tests/generated/flex/align_baseline_child.rs index 7f1275c97..4550d5e21 100644 --- a/tests/generated/flex/align_baseline_child.rs +++ b/tests/generated/flex/align_baseline_child.rs @@ -6,6 +6,7 @@ fn align_baseline_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_child__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_baseline_child__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -38,6 +44,10 @@ fn align_baseline_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -52,30 +62,170 @@ fn align_baseline_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +237,7 @@ fn align_baseline_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -97,6 +248,7 @@ fn align_baseline_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -109,6 +261,10 @@ fn align_baseline_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -122,6 +278,10 @@ fn align_baseline_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -136,28 +296,168 @@ fn align_baseline_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_margin.rs b/tests/generated/flex/align_baseline_child_margin.rs index 043519079..c3437bec9 100644 --- a/tests/generated/flex/align_baseline_child_margin.rs +++ b/tests/generated/flex/align_baseline_child_margin.rs @@ -6,6 +6,7 @@ fn align_baseline_child_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn align_baseline_child_margin__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -38,6 +40,10 @@ fn align_baseline_child_margin__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -50,6 +56,10 @@ fn align_baseline_child_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -64,30 +74,170 @@ fn align_baseline_child_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +249,7 @@ fn align_baseline_child_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -115,6 +266,7 @@ fn align_baseline_child_margin__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -133,6 +285,10 @@ fn align_baseline_child_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -146,6 +302,10 @@ fn align_baseline_child_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -160,28 +320,168 @@ fn align_baseline_child_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_margin_percent.rs b/tests/generated/flex/align_baseline_child_margin_percent.rs index 1264e859a..d59dfb790 100644 --- a/tests/generated/flex/align_baseline_child_margin_percent.rs +++ b/tests/generated/flex/align_baseline_child_margin_percent.rs @@ -6,6 +6,7 @@ fn align_baseline_child_margin_percent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn align_baseline_child_margin_percent__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -38,6 +40,10 @@ fn align_baseline_child_margin_percent__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -50,6 +56,10 @@ fn align_baseline_child_margin_percent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -64,30 +74,170 @@ fn align_baseline_child_margin_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +249,7 @@ fn align_baseline_child_margin_percent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -115,6 +266,7 @@ fn align_baseline_child_margin_percent__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -133,6 +285,10 @@ fn align_baseline_child_margin_percent__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -146,6 +302,10 @@ fn align_baseline_child_margin_percent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -160,28 +320,168 @@ fn align_baseline_child_margin_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_multiline.rs b/tests/generated/flex/align_baseline_child_multiline.rs index ff39590d4..9db8a372d 100644 --- a/tests/generated/flex/align_baseline_child_multiline.rs +++ b/tests/generated/flex/align_baseline_child_multiline.rs @@ -6,6 +6,7 @@ fn align_baseline_child_multiline__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -15,6 +16,7 @@ fn align_baseline_child_multiline__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn align_baseline_child_multiline__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_baseline_child_multiline__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn align_baseline_child_multiline__border_box() { .unwrap(); let node13 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -53,6 +58,10 @@ fn align_baseline_child_multiline__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -62,6 +71,10 @@ fn align_baseline_child_multiline__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -73,48 +86,305 @@ fn align_baseline_child_multiline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -126,6 +396,7 @@ fn align_baseline_child_multiline__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -136,6 +407,7 @@ fn align_baseline_child_multiline__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -146,6 +418,7 @@ fn align_baseline_child_multiline__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -156,6 +429,7 @@ fn align_baseline_child_multiline__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -166,6 +440,7 @@ fn align_baseline_child_multiline__content_box() { let node13 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -178,6 +453,10 @@ fn align_baseline_child_multiline__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -188,6 +467,10 @@ fn align_baseline_child_multiline__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -199,46 +482,303 @@ fn align_baseline_child_multiline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs b/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs index a24fdfba4..76229dc64 100644 --- a/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs +++ b/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs @@ -6,6 +6,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -15,6 +16,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { .unwrap(); let node13 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -54,6 +59,10 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(25f32), @@ -66,6 +75,10 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,48 +93,305 @@ fn align_baseline_child_multiline_no_override_on_secondline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -133,6 +403,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -143,6 +414,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -153,6 +425,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -163,6 +436,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -173,6 +447,7 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { let node13 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -186,6 +461,10 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(25f32), @@ -199,6 +478,10 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -213,46 +496,303 @@ fn align_baseline_child_multiline_no_override_on_secondline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_multiline_override.rs b/tests/generated/flex/align_baseline_child_multiline_override.rs index d746da7c6..596c292c6 100644 --- a/tests/generated/flex/align_baseline_child_multiline_override.rs +++ b/tests/generated/flex/align_baseline_child_multiline_override.rs @@ -6,6 +6,7 @@ fn align_baseline_child_multiline_override__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -15,6 +16,7 @@ fn align_baseline_child_multiline_override__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn align_baseline_child_multiline_override__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -34,6 +37,7 @@ fn align_baseline_child_multiline_override__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -43,6 +47,7 @@ fn align_baseline_child_multiline_override__border_box() { .unwrap(); let node13 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -55,6 +60,10 @@ fn align_baseline_child_multiline_override__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(25f32), @@ -67,6 +76,10 @@ fn align_baseline_child_multiline_override__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -81,48 +94,305 @@ fn align_baseline_child_multiline_override__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -134,6 +404,7 @@ fn align_baseline_child_multiline_override__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -144,6 +415,7 @@ fn align_baseline_child_multiline_override__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -154,6 +426,7 @@ fn align_baseline_child_multiline_override__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -165,6 +438,7 @@ fn align_baseline_child_multiline_override__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -175,6 +449,7 @@ fn align_baseline_child_multiline_override__content_box() { let node13 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -188,6 +463,10 @@ fn align_baseline_child_multiline_override__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(25f32), @@ -201,6 +480,10 @@ fn align_baseline_child_multiline_override__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -215,46 +498,303 @@ fn align_baseline_child_multiline_override__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_padding.rs b/tests/generated/flex/align_baseline_child_padding.rs index 41289e4dd..5d5bec3dd 100644 --- a/tests/generated/flex/align_baseline_child_padding.rs +++ b/tests/generated/flex/align_baseline_child_padding.rs @@ -6,6 +6,7 @@ fn align_baseline_child_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_child_padding__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_baseline_child_padding__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -44,6 +50,10 @@ fn align_baseline_child_padding__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -64,30 +74,170 @@ fn align_baseline_child_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +249,7 @@ fn align_baseline_child_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -109,6 +260,7 @@ fn align_baseline_child_padding__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +273,10 @@ fn align_baseline_child_padding__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +296,10 @@ fn align_baseline_child_padding__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -160,28 +320,168 @@ fn align_baseline_child_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 110f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_top.rs b/tests/generated/flex/align_baseline_child_top.rs index 4167de4d1..abd54482f 100644 --- a/tests/generated/flex/align_baseline_child_top.rs +++ b/tests/generated/flex/align_baseline_child_top.rs @@ -6,6 +6,7 @@ fn align_baseline_child_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -16,6 +17,7 @@ fn align_baseline_child_top__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,6 +29,10 @@ fn align_baseline_child_top__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -39,6 +45,10 @@ fn align_baseline_child_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -53,30 +63,170 @@ fn align_baseline_child_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -88,6 +238,7 @@ fn align_baseline_child_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -99,6 +250,7 @@ fn align_baseline_child_top__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -111,6 +263,10 @@ fn align_baseline_child_top__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -124,6 +280,10 @@ fn align_baseline_child_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -138,28 +298,168 @@ fn align_baseline_child_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_child_top2.rs b/tests/generated/flex/align_baseline_child_top2.rs index 96d9676cf..6d1311f33 100644 --- a/tests/generated/flex/align_baseline_child_top2.rs +++ b/tests/generated/flex/align_baseline_child_top2.rs @@ -6,6 +6,7 @@ fn align_baseline_child_top2__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_child_top2__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -25,6 +27,10 @@ fn align_baseline_child_top2__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -38,6 +44,10 @@ fn align_baseline_child_top2__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -52,30 +62,170 @@ fn align_baseline_child_top2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +237,7 @@ fn align_baseline_child_top2__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -97,6 +248,7 @@ fn align_baseline_child_top2__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -108,6 +260,10 @@ fn align_baseline_child_top2__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -122,6 +278,10 @@ fn align_baseline_child_top2__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -136,28 +296,168 @@ fn align_baseline_child_top2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_column.rs b/tests/generated/flex/align_baseline_column.rs index 2b44f51ef..51848b8a1 100644 --- a/tests/generated/flex/align_baseline_column.rs +++ b/tests/generated/flex/align_baseline_column.rs @@ -6,6 +6,7 @@ fn align_baseline_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,10 @@ fn align_baseline_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,24 +46,125 @@ fn align_baseline_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -69,6 +176,7 @@ fn align_baseline_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +187,7 @@ fn align_baseline_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -91,6 +200,10 @@ fn align_baseline_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -105,22 +218,123 @@ fn align_baseline_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_double_nested_child.rs b/tests/generated/flex/align_baseline_double_nested_child.rs index 7a59a865f..1ba9123e8 100644 --- a/tests/generated/flex/align_baseline_double_nested_child.rs +++ b/tests/generated/flex/align_baseline_double_nested_child.rs @@ -6,6 +6,7 @@ fn align_baseline_double_nested_child__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,10 @@ fn align_baseline_double_nested_child__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -27,6 +32,7 @@ fn align_baseline_double_nested_child__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -37,6 +43,10 @@ fn align_baseline_double_nested_child__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -49,6 +59,10 @@ fn align_baseline_double_nested_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -63,36 +77,215 @@ fn align_baseline_double_nested_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -104,6 +297,7 @@ fn align_baseline_double_nested_child__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -115,6 +309,10 @@ fn align_baseline_double_nested_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -127,6 +325,7 @@ fn align_baseline_double_nested_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -138,6 +337,10 @@ fn align_baseline_double_nested_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -151,6 +354,10 @@ fn align_baseline_double_nested_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -165,34 +372,213 @@ fn align_baseline_double_nested_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_multiline.rs b/tests/generated/flex/align_baseline_multiline.rs index 9486c0eaf..ab2961dea 100644 --- a/tests/generated/flex/align_baseline_multiline.rs +++ b/tests/generated/flex/align_baseline_multiline.rs @@ -6,6 +6,7 @@ fn align_baseline_multiline__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_multiline__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -37,6 +43,7 @@ fn align_baseline_multiline__border_box() { .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -48,6 +55,10 @@ fn align_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -59,6 +70,7 @@ fn align_baseline_multiline__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -70,6 +82,10 @@ fn align_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -84,48 +100,293 @@ fn align_baseline_multiline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -137,6 +398,7 @@ fn align_baseline_multiline__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -147,6 +409,7 @@ fn align_baseline_multiline__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +422,10 @@ fn align_baseline_multiline__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -171,6 +438,7 @@ fn align_baseline_multiline__content_box() { let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -183,6 +451,10 @@ fn align_baseline_multiline__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -195,6 +467,7 @@ fn align_baseline_multiline__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -207,6 +480,10 @@ fn align_baseline_multiline__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -221,46 +498,291 @@ fn align_baseline_multiline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_multiline_column.rs b/tests/generated/flex/align_baseline_multiline_column.rs index 6fbb45416..41233bba6 100644 --- a/tests/generated/flex/align_baseline_multiline_column.rs +++ b/tests/generated/flex/align_baseline_multiline_column.rs @@ -6,6 +6,7 @@ fn align_baseline_multiline_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_multiline_column__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,10 @@ fn align_baseline_multiline_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -37,6 +43,7 @@ fn align_baseline_multiline_column__border_box() { .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -48,6 +55,10 @@ fn align_baseline_multiline_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -59,6 +70,7 @@ fn align_baseline_multiline_column__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -71,6 +83,10 @@ fn align_baseline_multiline_column__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -85,48 +101,293 @@ fn align_baseline_multiline_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -138,6 +399,7 @@ fn align_baseline_multiline_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -148,6 +410,7 @@ fn align_baseline_multiline_column__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +423,10 @@ fn align_baseline_multiline_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -172,6 +439,7 @@ fn align_baseline_multiline_column__content_box() { let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -184,6 +452,10 @@ fn align_baseline_multiline_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -196,6 +468,7 @@ fn align_baseline_multiline_column__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -209,6 +482,10 @@ fn align_baseline_multiline_column__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -223,46 +500,291 @@ fn align_baseline_multiline_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_multiline_column2.rs b/tests/generated/flex/align_baseline_multiline_column2.rs index a79ad8d42..e5608af8c 100644 --- a/tests/generated/flex/align_baseline_multiline_column2.rs +++ b/tests/generated/flex/align_baseline_multiline_column2.rs @@ -7,6 +7,7 @@ fn align_baseline_multiline_column2__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn align_baseline_multiline_column2__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -28,6 +30,10 @@ fn align_baseline_multiline_column2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -40,6 +46,7 @@ fn align_baseline_multiline_column2__border_box() { let node20 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +58,10 @@ fn align_baseline_multiline_column2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -63,6 +74,7 @@ fn align_baseline_multiline_column2__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -75,6 +87,10 @@ fn align_baseline_multiline_column2__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -89,48 +105,293 @@ fn align_baseline_multiline_column2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,6 +404,7 @@ fn align_baseline_multiline_column2__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -154,6 +416,7 @@ fn align_baseline_multiline_column2__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -166,6 +429,10 @@ fn align_baseline_multiline_column2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -179,6 +446,7 @@ fn align_baseline_multiline_column2__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +459,10 @@ fn align_baseline_multiline_column2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -204,6 +476,7 @@ fn align_baseline_multiline_column2__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -217,6 +490,10 @@ fn align_baseline_multiline_column2__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -231,46 +508,291 @@ fn align_baseline_multiline_column2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_multiline_row_and_column.rs b/tests/generated/flex/align_baseline_multiline_row_and_column.rs index 14d3e56b3..946fcd12b 100644 --- a/tests/generated/flex/align_baseline_multiline_row_and_column.rs +++ b/tests/generated/flex/align_baseline_multiline_row_and_column.rs @@ -6,6 +6,7 @@ fn align_baseline_multiline_row_and_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_multiline_row_and_column__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -37,6 +43,7 @@ fn align_baseline_multiline_row_and_column__border_box() { .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -48,6 +55,10 @@ fn align_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -59,6 +70,7 @@ fn align_baseline_multiline_row_and_column__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -70,6 +82,10 @@ fn align_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -84,48 +100,293 @@ fn align_baseline_multiline_row_and_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -137,6 +398,7 @@ fn align_baseline_multiline_row_and_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -147,6 +409,7 @@ fn align_baseline_multiline_row_and_column__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +422,10 @@ fn align_baseline_multiline_row_and_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -171,6 +438,7 @@ fn align_baseline_multiline_row_and_column__content_box() { let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -183,6 +451,10 @@ fn align_baseline_multiline_row_and_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -195,6 +467,7 @@ fn align_baseline_multiline_row_and_column__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -207,6 +480,10 @@ fn align_baseline_multiline_row_and_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -221,46 +498,291 @@ fn align_baseline_multiline_row_and_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_nested_child.rs b/tests/generated/flex/align_baseline_nested_child.rs index a2dd67948..58973ee9c 100644 --- a/tests/generated/flex/align_baseline_nested_child.rs +++ b/tests/generated/flex/align_baseline_nested_child.rs @@ -6,6 +6,7 @@ fn align_baseline_nested_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_baseline_nested_child__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_baseline_nested_child__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -38,6 +44,10 @@ fn align_baseline_nested_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -52,30 +62,170 @@ fn align_baseline_nested_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +237,7 @@ fn align_baseline_nested_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -97,6 +248,7 @@ fn align_baseline_nested_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -109,6 +261,10 @@ fn align_baseline_nested_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -122,6 +278,10 @@ fn align_baseline_nested_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -136,28 +296,168 @@ fn align_baseline_nested_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_baseline_nested_column.rs b/tests/generated/flex/align_baseline_nested_column.rs index 528a06661..9bf0aeb62 100644 --- a/tests/generated/flex/align_baseline_nested_column.rs +++ b/tests/generated/flex/align_baseline_nested_column.rs @@ -6,6 +6,7 @@ fn align_baseline_nested_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -16,6 +17,7 @@ fn align_baseline_nested_column__border_box() { let node100 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(30f32), @@ -26,6 +28,7 @@ fn align_baseline_nested_column__border_box() { let node101 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(40f32), @@ -37,6 +40,10 @@ fn align_baseline_nested_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(80f32), @@ -48,13 +55,24 @@ fn align_baseline_nested_column__border_box() { .unwrap(); let node1 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node10], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -69,42 +87,260 @@ fn align_baseline_nested_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node101, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -116,6 +352,7 @@ fn align_baseline_nested_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -127,6 +364,7 @@ fn align_baseline_nested_column__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(30f32), @@ -138,6 +376,7 @@ fn align_baseline_nested_column__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(40f32), @@ -150,6 +389,10 @@ fn align_baseline_nested_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(80f32), @@ -164,6 +407,10 @@ fn align_baseline_nested_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node10], @@ -173,6 +420,10 @@ fn align_baseline_nested_column__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -187,40 +438,258 @@ fn align_baseline_nested_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node101, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_center_should_size_based_on_content.rs b/tests/generated/flex/align_center_should_size_based_on_content.rs index 86f432426..aab80b056 100644 --- a/tests/generated/flex/align_center_should_size_based_on_content.rs +++ b/tests/generated/flex/align_center_should_size_based_on_content.rs @@ -6,6 +6,7 @@ fn align_center_should_size_based_on_content__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -14,11 +15,26 @@ fn align_center_should_size_based_on_content__border_box() { }) .unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, @@ -30,6 +46,10 @@ fn align_center_should_size_based_on_content__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -44,30 +64,176 @@ fn align_center_should_size_based_on_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +245,7 @@ fn align_center_should_size_based_on_content__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -90,6 +257,10 @@ fn align_center_should_size_based_on_content__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -101,6 +272,10 @@ fn align_center_should_size_based_on_content__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, @@ -113,6 +288,10 @@ fn align_center_should_size_based_on_content__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -127,28 +306,174 @@ fn align_center_should_size_based_on_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_single_line.rs b/tests/generated/flex/align_content_center_single_line.rs index 0fdfdc8ff..2ddcb997f 100644 --- a/tests/generated/flex/align_content_center_single_line.rs +++ b/tests/generated/flex/align_content_center_single_line.rs @@ -6,6 +6,7 @@ fn align_content_center_single_line__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_center_single_line__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_center_single_line__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_center_single_line__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_center_single_line__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_center_single_line__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -61,6 +67,10 @@ fn align_content_center_single_line__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -75,48 +85,281 @@ fn align_content_center_single_line__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node5, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -128,6 +371,7 @@ fn align_content_center_single_line__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +382,7 @@ fn align_content_center_single_line__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -148,6 +393,7 @@ fn align_content_center_single_line__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -158,6 +404,7 @@ fn align_content_center_single_line__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +415,7 @@ fn align_content_center_single_line__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -178,6 +426,7 @@ fn align_content_center_single_line__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -189,6 +438,10 @@ fn align_content_center_single_line__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -203,46 +456,279 @@ fn align_content_center_single_line__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node5, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_single_line_negative_space.rs b/tests/generated/flex/align_content_center_single_line_negative_space.rs index 95f07d548..1fb225a1e 100644 --- a/tests/generated/flex/align_content_center_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_center_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_center_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_center_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_center_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_center_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_center_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_center_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_center_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_center_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs index da7fa7cee..9e203588b 100644 --- a/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_center_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_center_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_center_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_center_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_center_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_center_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_center_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_center_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_wrapped.rs b/tests/generated/flex/align_content_center_wrapped.rs index a956446e7..786e481fe 100644 --- a/tests/generated/flex/align_content_center_wrapped.rs +++ b/tests/generated/flex/align_content_center_wrapped.rs @@ -6,6 +6,7 @@ fn align_content_center_wrapped__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_center_wrapped__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_center_wrapped__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_center_wrapped__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_center_wrapped__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_center_wrapped__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -62,6 +68,10 @@ fn align_content_center_wrapped__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -76,48 +86,281 @@ fn align_content_center_wrapped__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node0, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node4, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node5, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +372,7 @@ fn align_content_center_wrapped__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -139,6 +383,7 @@ fn align_content_center_wrapped__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -149,6 +394,7 @@ fn align_content_center_wrapped__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +405,7 @@ fn align_content_center_wrapped__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -169,6 +416,7 @@ fn align_content_center_wrapped__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -179,6 +427,7 @@ fn align_content_center_wrapped__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +440,10 @@ fn align_content_center_wrapped__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -205,46 +458,279 @@ fn align_content_center_wrapped__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node0, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node4, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node5, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_wrapped_negative_space.rs b/tests/generated/flex/align_content_center_wrapped_negative_space.rs index f436fdb82..00786398a 100644 --- a/tests/generated/flex/align_content_center_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_center_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_center_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_center_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_center_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_center_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_center_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_center_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node00, -25f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node02, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_center_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_center_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_center_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_center_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_center_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_center_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node00, -25f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node02, 15f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs b/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs index b724454ca..53c247720 100644 --- a/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs +++ b/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn align_content_center_wrapped_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 35f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 35f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -35f32, "y of node {:?}. Expected {}. Actual {}", node00, -35f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node02, 25f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn align_content_center_wrapped_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 35f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 35f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -35f32, "y of node {:?}. Expected {}. Actual {}", node00, -35f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node02, 25f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_end.rs b/tests/generated/flex/align_content_end.rs index da97fd0ef..023ad5fdb 100644 --- a/tests/generated/flex/align_content_end.rs +++ b/tests/generated/flex/align_content_end.rs @@ -6,6 +6,7 @@ fn align_content_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_end__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_end__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_end__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -54,6 +59,10 @@ fn align_content_end__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -68,42 +77,242 @@ fn align_content_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -115,6 +324,7 @@ fn align_content_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -125,6 +335,7 @@ fn align_content_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -135,6 +346,7 @@ fn align_content_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -145,6 +357,7 @@ fn align_content_end__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -155,6 +368,7 @@ fn align_content_end__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +382,10 @@ fn align_content_end__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -182,40 +400,240 @@ fn align_content_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_end_single_line_negative_space.rs b/tests/generated/flex/align_content_end_single_line_negative_space.rs index c8fce156f..09005d3dc 100644 --- a/tests/generated/flex/align_content_end_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_end_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_end_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_end_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_end_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_end_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_end_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_end_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_end_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_end_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs index 1a6354b2d..96acd3192 100644 --- a/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_end_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_end_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_end_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_end_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_end_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_end_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_end_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_end_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_end_wrapped_negative_space.rs b/tests/generated/flex/align_content_end_wrapped_negative_space.rs index 530a23c38..b8823d3aa 100644 --- a/tests/generated/flex/align_content_end_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_end_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_end_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_end_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_end_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_end_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_end_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_end_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node00, -50f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -30f32, "y of node {:?}. Expected {}. Actual {}", node01, -30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_end_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_end_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_end_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_end_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_end_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_end_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node00, -50f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -30f32, "y of node {:?}. Expected {}. Actual {}", node01, -30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs b/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs index 60633a9ad..f809bc77b 100644 --- a/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs +++ b/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn align_content_end_wrapped_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -70f32, "y of node {:?}. Expected {}. Actual {}", node00, -70f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -40f32, "y of node {:?}. Expected {}. Actual {}", node01, -40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn align_content_end_wrapped_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -70f32, "y of node {:?}. Expected {}. Actual {}", node00, -70f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -40f32, "y of node {:?}. Expected {}. Actual {}", node01, -40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_flex_end.rs b/tests/generated/flex/align_content_flex_end.rs index 6148dab06..f8b072712 100644 --- a/tests/generated/flex/align_content_flex_end.rs +++ b/tests/generated/flex/align_content_flex_end.rs @@ -6,6 +6,7 @@ fn align_content_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_flex_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_flex_end__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_flex_end__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_flex_end__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -54,6 +59,10 @@ fn align_content_flex_end__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -68,42 +77,242 @@ fn align_content_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -115,6 +324,7 @@ fn align_content_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -125,6 +335,7 @@ fn align_content_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -135,6 +346,7 @@ fn align_content_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -145,6 +357,7 @@ fn align_content_flex_end__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -155,6 +368,7 @@ fn align_content_flex_end__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +382,10 @@ fn align_content_flex_end__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -182,40 +400,240 @@ fn align_content_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_flex_start.rs b/tests/generated/flex/align_content_flex_start.rs index fab369af9..e3a2cc397 100644 --- a/tests/generated/flex/align_content_flex_start.rs +++ b/tests/generated/flex/align_content_flex_start.rs @@ -6,6 +6,7 @@ fn align_content_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_flex_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_flex_start__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_flex_start__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_flex_start__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -53,6 +58,10 @@ fn align_content_flex_start__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -67,42 +76,242 @@ fn align_content_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,6 +323,7 @@ fn align_content_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -124,6 +334,7 @@ fn align_content_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -134,6 +345,7 @@ fn align_content_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -144,6 +356,7 @@ fn align_content_flex_start__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -154,6 +367,7 @@ fn align_content_flex_start__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +380,10 @@ fn align_content_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -180,40 +398,240 @@ fn align_content_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_flex_start_with_flex.rs b/tests/generated/flex/align_content_flex_start_with_flex.rs index 31c595a4a..ea9634df9 100644 --- a/tests/generated/flex/align_content_flex_start_with_flex.rs +++ b/tests/generated/flex/align_content_flex_start_with_flex.rs @@ -6,6 +6,7 @@ fn align_content_flex_start_with_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -15,6 +16,7 @@ fn align_content_flex_start_with_flex__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -27,12 +29,14 @@ fn align_content_flex_start_with_flex__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -42,6 +46,7 @@ fn align_content_flex_start_with_flex__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -51,6 +56,10 @@ fn align_content_flex_start_with_flex__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -65,42 +74,242 @@ fn align_content_flex_start_with_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node4, 120f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +321,7 @@ fn align_content_flex_start_with_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -122,6 +332,7 @@ fn align_content_flex_start_with_flex__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -135,6 +346,7 @@ fn align_content_flex_start_with_flex__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -142,6 +354,7 @@ fn align_content_flex_start_with_flex__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -152,6 +365,7 @@ fn align_content_flex_start_with_flex__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -162,6 +376,10 @@ fn align_content_flex_start_with_flex__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -176,40 +394,240 @@ fn align_content_flex_start_with_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node4, 120f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_flex_start_without_height_on_children.rs b/tests/generated/flex/align_content_flex_start_without_height_on_children.rs index 5fe08925b..765c029be 100644 --- a/tests/generated/flex/align_content_flex_start_without_height_on_children.rs +++ b/tests/generated/flex/align_content_flex_start_without_height_on_children.rs @@ -6,12 +6,14 @@ fn align_content_flex_start_without_height_on_children__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,12 +23,14 @@ fn align_content_flex_start_without_height_on_children__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -36,6 +40,7 @@ fn align_content_flex_start_without_height_on_children__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -45,6 +50,10 @@ fn align_content_flex_start_without_height_on_children__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -59,42 +68,242 @@ fn align_content_flex_start_without_height_on_children__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -106,6 +315,7 @@ fn align_content_flex_start_without_height_on_children__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -113,6 +323,7 @@ fn align_content_flex_start_without_height_on_children__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -123,6 +334,7 @@ fn align_content_flex_start_without_height_on_children__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -130,6 +342,7 @@ fn align_content_flex_start_without_height_on_children__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -140,6 +353,7 @@ fn align_content_flex_start_without_height_on_children__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -150,6 +364,10 @@ fn align_content_flex_start_without_height_on_children__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -164,40 +382,240 @@ fn align_content_flex_start_without_height_on_children__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs b/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs index 09b055b2b..d0c35b864 100644 --- a/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs +++ b/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs @@ -6,6 +6,7 @@ fn align_content_not_stretch_with_align_items_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(272f32), height: taffy::style::Dimension::from_length(44f32), @@ -15,12 +16,20 @@ fn align_content_not_stretch_with_align_items_stretch__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(56f32), height: taffy::style::Dimension::from_length(44f32), @@ -30,7 +39,14 @@ fn align_content_not_stretch_with_align_items_stretch__border_box() { .unwrap(); let node1 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node10], ) .unwrap(); @@ -38,6 +54,10 @@ fn align_content_not_stretch_with_align_items_stretch__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(328f32), @@ -52,36 +72,215 @@ fn align_content_not_stretch_with_align_items_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 328f32, "width of node {:?}. Expected {}. Actual {}", node, 328f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 328f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 328f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node0, 272f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node00, 272f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node00, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 44f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node1, 56f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node1, 44f32, size.height); - assert_eq!(location.x, 272f32, "x of node {:?}. Expected {}. Actual {}", node1, 272f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 56f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 272f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node10, 56f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node10, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 56f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 44f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -93,6 +292,7 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(272f32), height: taffy::style::Dimension::from_length(44f32), @@ -105,6 +305,10 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -113,6 +317,7 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(56f32), height: taffy::style::Dimension::from_length(44f32), @@ -125,6 +330,10 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node10], @@ -135,6 +344,10 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(328f32), @@ -149,34 +362,213 @@ fn align_content_not_stretch_with_align_items_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 328f32, "width of node {:?}. Expected {}. Actual {}", node, 328f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 328f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 328f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node0, 272f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node00, 272f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node00, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 44f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node1, 56f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node1, 44f32, size.height); - assert_eq!(location.x, 272f32, "x of node {:?}. Expected {}. Actual {}", node1, 272f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 56f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 272f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node10, 56f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node10, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 56f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 44f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_single_line.rs b/tests/generated/flex/align_content_space_around_single_line.rs index ae519034b..7e2b301d2 100644 --- a/tests/generated/flex/align_content_space_around_single_line.rs +++ b/tests/generated/flex/align_content_space_around_single_line.rs @@ -6,6 +6,7 @@ fn align_content_space_around_single_line__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_around_single_line__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_around_single_line__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_around_single_line__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_around_single_line__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_around_single_line__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -61,6 +67,10 @@ fn align_content_space_around_single_line__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -75,48 +85,281 @@ fn align_content_space_around_single_line__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node0, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 17f32, "x of node {:?}. Expected {}. Actual {}", node1, 17f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 17f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node2, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node3, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node4, 16f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node4, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node5, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 83f32, "x of node {:?}. Expected {}. Actual {}", node5, 83f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 83f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 83f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -128,6 +371,7 @@ fn align_content_space_around_single_line__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +382,7 @@ fn align_content_space_around_single_line__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -148,6 +393,7 @@ fn align_content_space_around_single_line__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -158,6 +404,7 @@ fn align_content_space_around_single_line__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +415,7 @@ fn align_content_space_around_single_line__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -178,6 +426,7 @@ fn align_content_space_around_single_line__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -189,6 +438,10 @@ fn align_content_space_around_single_line__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -203,46 +456,279 @@ fn align_content_space_around_single_line__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node0, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 17f32, "x of node {:?}. Expected {}. Actual {}", node1, 17f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 17f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node2, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node3, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node4, 16f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node4, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node5, 17f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 83f32, "x of node {:?}. Expected {}. Actual {}", node5, 83f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 83f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 83f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_single_line_negative_space.rs b/tests/generated/flex/align_content_space_around_single_line_negative_space.rs index 093880705..af09ec015 100644 --- a/tests/generated/flex/align_content_space_around_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_space_around_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_around_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_around_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_space_around_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_space_around_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_space_around_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_space_around_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_space_around_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_space_around_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs index 71eb96c4c..872e5d931 100644 --- a/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_around_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_around_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_space_around_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_space_around_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_space_around_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_space_around_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_space_around_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_space_around_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_wrapped.rs b/tests/generated/flex/align_content_space_around_wrapped.rs index ba33b241d..abf96085c 100644 --- a/tests/generated/flex/align_content_space_around_wrapped.rs +++ b/tests/generated/flex/align_content_space_around_wrapped.rs @@ -6,6 +6,7 @@ fn align_content_space_around_wrapped__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_around_wrapped__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_around_wrapped__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_around_wrapped__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_around_wrapped__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_around_wrapped__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -62,6 +68,10 @@ fn align_content_space_around_wrapped__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,48 +86,281 @@ fn align_content_space_around_wrapped__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node4, 78f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node5, 78f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +372,7 @@ fn align_content_space_around_wrapped__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -139,6 +383,7 @@ fn align_content_space_around_wrapped__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -149,6 +394,7 @@ fn align_content_space_around_wrapped__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +405,7 @@ fn align_content_space_around_wrapped__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -169,6 +416,7 @@ fn align_content_space_around_wrapped__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -179,6 +427,7 @@ fn align_content_space_around_wrapped__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +440,10 @@ fn align_content_space_around_wrapped__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -205,46 +458,279 @@ fn align_content_space_around_wrapped__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node4, 78f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node5, 78f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs b/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs index 91ff7bad7..9f14dcc00 100644 --- a/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_around_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_around_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_around_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_around_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_space_around_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_space_around_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_space_around_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_space_around_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_space_around_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_space_around_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_space_around_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_space_around_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs b/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs index 52fe687ed..03cf58998 100644 --- a/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn align_content_space_around_wrapped_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn align_content_space_around_wrapped_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_around_wrapped_single.rs b/tests/generated/flex/align_content_space_around_wrapped_single.rs index 742a49f55..5ab770f8f 100644 --- a/tests/generated/flex/align_content_space_around_wrapped_single.rs +++ b/tests/generated/flex/align_content_space_around_wrapped_single.rs @@ -6,6 +6,7 @@ fn align_content_space_around_wrapped_single__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_content_space_around_wrapped_single__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_content_space_around_wrapped_single__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_content_space_around_wrapped_single__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_content_space_around_wrapped_single__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_content_space_around_wrapped_single__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_single_line.rs b/tests/generated/flex/align_content_space_between_single_line.rs index 9333efa54..f64791baf 100644 --- a/tests/generated/flex/align_content_space_between_single_line.rs +++ b/tests/generated/flex/align_content_space_between_single_line.rs @@ -6,6 +6,7 @@ fn align_content_space_between_single_line__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_between_single_line__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_between_single_line__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_between_single_line__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_between_single_line__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_between_single_line__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -61,6 +67,10 @@ fn align_content_space_between_single_line__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -75,48 +85,281 @@ fn align_content_space_between_single_line__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -128,6 +371,7 @@ fn align_content_space_between_single_line__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +382,7 @@ fn align_content_space_between_single_line__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -148,6 +393,7 @@ fn align_content_space_between_single_line__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -158,6 +404,7 @@ fn align_content_space_between_single_line__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +415,7 @@ fn align_content_space_between_single_line__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -178,6 +426,7 @@ fn align_content_space_between_single_line__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -189,6 +438,10 @@ fn align_content_space_between_single_line__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -203,46 +456,279 @@ fn align_content_space_between_single_line__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_single_line_negative_space.rs b/tests/generated/flex/align_content_space_between_single_line_negative_space.rs index c80920b29..3eeb20311 100644 --- a/tests/generated/flex/align_content_space_between_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_space_between_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_between_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_between_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_space_between_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_space_between_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_space_between_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_space_between_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_space_between_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_space_between_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs index b411bbb54..1464089c2 100644 --- a/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_between_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_between_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_space_between_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_space_between_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_space_between_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_space_between_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_space_between_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_space_between_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_wrapped.rs b/tests/generated/flex/align_content_space_between_wrapped.rs index 9882fca89..2a286767d 100644 --- a/tests/generated/flex/align_content_space_between_wrapped.rs +++ b/tests/generated/flex/align_content_space_between_wrapped.rs @@ -6,6 +6,7 @@ fn align_content_space_between_wrapped__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_between_wrapped__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_between_wrapped__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_between_wrapped__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_between_wrapped__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_between_wrapped__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -62,6 +68,10 @@ fn align_content_space_between_wrapped__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,48 +86,281 @@ fn align_content_space_between_wrapped__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node5, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +372,7 @@ fn align_content_space_between_wrapped__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -139,6 +383,7 @@ fn align_content_space_between_wrapped__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -149,6 +394,7 @@ fn align_content_space_between_wrapped__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +405,7 @@ fn align_content_space_between_wrapped__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -169,6 +416,7 @@ fn align_content_space_between_wrapped__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -179,6 +427,7 @@ fn align_content_space_between_wrapped__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +440,10 @@ fn align_content_space_between_wrapped__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -205,46 +458,279 @@ fn align_content_space_between_wrapped__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node5, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs b/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs index 2cdd90f80..ad6babb33 100644 --- a/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_between_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_between_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_between_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_between_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_space_between_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_space_between_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_space_between_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_space_between_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_space_between_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_space_between_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_space_between_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_space_between_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs b/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs index 9cca0ec7d..f3c81bda6 100644 --- a/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn align_content_space_between_wrapped_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn align_content_space_between_wrapped_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_between_wrapped_single.rs b/tests/generated/flex/align_content_space_between_wrapped_single.rs index be2096a71..333d0d5b3 100644 --- a/tests/generated/flex/align_content_space_between_wrapped_single.rs +++ b/tests/generated/flex/align_content_space_between_wrapped_single.rs @@ -6,6 +6,7 @@ fn align_content_space_between_wrapped_single__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_content_space_between_wrapped_single__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_content_space_between_wrapped_single__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_content_space_between_wrapped_single__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_content_space_between_wrapped_single__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_content_space_between_wrapped_single__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_single_line.rs b/tests/generated/flex/align_content_space_evenly_single_line.rs index ec807c1d9..a10994f39 100644 --- a/tests/generated/flex/align_content_space_evenly_single_line.rs +++ b/tests/generated/flex/align_content_space_evenly_single_line.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_single_line__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_evenly_single_line__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_evenly_single_line__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_evenly_single_line__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_evenly_single_line__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_evenly_single_line__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -61,6 +67,10 @@ fn align_content_space_evenly_single_line__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -75,48 +85,281 @@ fn align_content_space_evenly_single_line__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -128,6 +371,7 @@ fn align_content_space_evenly_single_line__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +382,7 @@ fn align_content_space_evenly_single_line__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -148,6 +393,7 @@ fn align_content_space_evenly_single_line__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -158,6 +404,7 @@ fn align_content_space_evenly_single_line__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +415,7 @@ fn align_content_space_evenly_single_line__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -178,6 +426,7 @@ fn align_content_space_evenly_single_line__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -189,6 +438,10 @@ fn align_content_space_evenly_single_line__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -203,46 +456,279 @@ fn align_content_space_evenly_single_line__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs b/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs index d96fe71c8..04e741a7e 100644 --- a/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_evenly_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_space_evenly_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_space_evenly_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_space_evenly_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_space_evenly_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_space_evenly_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_space_evenly_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs index 79971eed9..6f8b59071 100644 --- a/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_space_evenly_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_space_evenly_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_space_evenly_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_space_evenly_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_space_evenly_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_space_evenly_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_space_evenly_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_wrapped.rs b/tests/generated/flex/align_content_space_evenly_wrapped.rs index 035880351..1c0c3ba85 100644 --- a/tests/generated/flex/align_content_space_evenly_wrapped.rs +++ b/tests/generated/flex/align_content_space_evenly_wrapped.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_wrapped__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_space_evenly_wrapped__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_space_evenly_wrapped__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_space_evenly_wrapped__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_space_evenly_wrapped__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +56,7 @@ fn align_content_space_evenly_wrapped__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -62,6 +68,10 @@ fn align_content_space_evenly_wrapped__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,48 +86,281 @@ fn align_content_space_evenly_wrapped__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node1, 18f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node4, 73f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node5, 73f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +372,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -139,6 +383,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -149,6 +394,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +405,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -169,6 +416,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -179,6 +427,7 @@ fn align_content_space_evenly_wrapped__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +440,10 @@ fn align_content_space_evenly_wrapped__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -205,46 +458,279 @@ fn align_content_space_evenly_wrapped__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node1, 18f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node4, 73f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node5, 73f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs b/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs index 3a1a5b960..2b53f4921 100644 --- a/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_space_evenly_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_space_evenly_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs b/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs index 795d57e2d..a7b39fe87 100644 --- a/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs +++ b/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn align_content_space_evenly_wrapped_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn align_content_space_evenly_wrapped_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_space_evenly_wrapped_single.rs b/tests/generated/flex/align_content_space_evenly_wrapped_single.rs index 7197de41a..9d0b9fb0f 100644 --- a/tests/generated/flex/align_content_space_evenly_wrapped_single.rs +++ b/tests/generated/flex/align_content_space_evenly_wrapped_single.rs @@ -6,6 +6,7 @@ fn align_content_space_evenly_wrapped_single__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_content_space_evenly_wrapped_single__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_content_space_evenly_wrapped_single__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_content_space_evenly_wrapped_single__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_content_space_evenly_wrapped_single__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_content_space_evenly_wrapped_single__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_spacearound.rs b/tests/generated/flex/align_content_spacearound.rs index 99753e65d..c074054ec 100644 --- a/tests/generated/flex/align_content_spacearound.rs +++ b/tests/generated/flex/align_content_spacearound.rs @@ -6,6 +6,7 @@ fn align_content_spacearound__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_spacearound__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_spacearound__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_spacearound__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_spacearound__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -53,6 +58,10 @@ fn align_content_spacearound__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(140f32), @@ -67,42 +76,242 @@ fn align_content_spacearound__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node3, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 95f32, "y of node {:?}. Expected {}. Actual {}", node4, 95f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 95f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,6 +323,7 @@ fn align_content_spacearound__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -124,6 +334,7 @@ fn align_content_spacearound__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -134,6 +345,7 @@ fn align_content_spacearound__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -144,6 +356,7 @@ fn align_content_spacearound__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -154,6 +367,7 @@ fn align_content_spacearound__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +380,10 @@ fn align_content_spacearound__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(140f32), @@ -180,40 +398,240 @@ fn align_content_spacearound__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node3, 55f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 95f32, "y of node {:?}. Expected {}. Actual {}", node4, 95f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 95f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_spacebetween.rs b/tests/generated/flex/align_content_spacebetween.rs index d288069b4..361eb3c3e 100644 --- a/tests/generated/flex/align_content_spacebetween.rs +++ b/tests/generated/flex/align_content_spacebetween.rs @@ -6,6 +6,7 @@ fn align_content_spacebetween__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_spacebetween__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_spacebetween__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_spacebetween__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_spacebetween__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -53,6 +58,10 @@ fn align_content_spacebetween__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -67,42 +76,242 @@ fn align_content_spacebetween__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,6 +323,7 @@ fn align_content_spacebetween__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -124,6 +334,7 @@ fn align_content_spacebetween__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -134,6 +345,7 @@ fn align_content_spacebetween__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -144,6 +356,7 @@ fn align_content_spacebetween__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -154,6 +367,7 @@ fn align_content_spacebetween__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +380,10 @@ fn align_content_spacebetween__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -180,40 +398,240 @@ fn align_content_spacebetween__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_start.rs b/tests/generated/flex/align_content_start.rs index 8d95f99c3..d694e0dbc 100644 --- a/tests/generated/flex/align_content_start.rs +++ b/tests/generated/flex/align_content_start.rs @@ -6,6 +6,7 @@ fn align_content_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_content_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -24,6 +26,7 @@ fn align_content_start__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -33,6 +36,7 @@ fn align_content_start__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -42,6 +46,7 @@ fn align_content_start__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -53,6 +58,10 @@ fn align_content_start__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -67,42 +76,242 @@ fn align_content_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,6 +323,7 @@ fn align_content_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -124,6 +334,7 @@ fn align_content_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -134,6 +345,7 @@ fn align_content_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -144,6 +356,7 @@ fn align_content_start__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -154,6 +367,7 @@ fn align_content_start__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +380,10 @@ fn align_content_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(130f32), @@ -180,40 +398,240 @@ fn align_content_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_start_single_line_negative_space.rs b/tests/generated/flex/align_content_start_single_line_negative_space.rs index adbc38e2f..1ca64cc00 100644 --- a/tests/generated/flex/align_content_start_single_line_negative_space.rs +++ b/tests/generated/flex/align_content_start_single_line_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_start_single_line_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_start_single_line_negative_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -31,6 +36,10 @@ fn align_content_start_single_line_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -50,24 +59,131 @@ fn align_content_start_single_line_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +195,7 @@ fn align_content_start_single_line_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -92,6 +209,10 @@ fn align_content_start_single_line_negative_space__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -106,6 +227,10 @@ fn align_content_start_single_line_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -125,22 +250,129 @@ fn align_content_start_single_line_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs b/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs index 8d6c00d57..abd0478e7 100644 --- a/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs +++ b/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs @@ -6,6 +6,7 @@ fn align_content_start_single_line_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -18,6 +19,10 @@ fn align_content_start_single_line_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -32,6 +37,10 @@ fn align_content_start_single_line_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -51,24 +60,131 @@ fn align_content_start_single_line_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +196,7 @@ fn align_content_start_single_line_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -93,6 +210,10 @@ fn align_content_start_single_line_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -108,6 +229,10 @@ fn align_content_start_single_line_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -127,22 +252,129 @@ fn align_content_start_single_line_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_start_wrapped_negative_space.rs b/tests/generated/flex/align_content_start_wrapped_negative_space.rs index 3a079bcb9..47dab5f33 100644 --- a/tests/generated/flex/align_content_start_wrapped_negative_space.rs +++ b/tests/generated/flex/align_content_start_wrapped_negative_space.rs @@ -6,6 +6,7 @@ fn align_content_start_wrapped_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn align_content_start_wrapped_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn align_content_start_wrapped_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn align_content_start_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn align_content_start_wrapped_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn align_content_start_wrapped_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn align_content_start_wrapped_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn align_content_start_wrapped_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn align_content_start_wrapped_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn align_content_start_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn align_content_start_wrapped_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn align_content_start_wrapped_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch.rs b/tests/generated/flex/align_content_stretch.rs index 269dc7415..a9fc44cdd 100644 --- a/tests/generated/flex/align_content_stretch.rs +++ b/tests/generated/flex/align_content_stretch.rs @@ -6,30 +6,35 @@ fn align_content_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -39,6 +44,10 @@ fn align_content_stretch__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -53,42 +62,242 @@ fn align_content_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +309,7 @@ fn align_content_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -107,6 +317,7 @@ fn align_content_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -114,6 +325,7 @@ fn align_content_stretch__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -121,6 +333,7 @@ fn align_content_stretch__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -128,6 +341,7 @@ fn align_content_stretch__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -138,6 +352,10 @@ fn align_content_stretch__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -152,40 +370,240 @@ fn align_content_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_column.rs b/tests/generated/flex/align_content_stretch_column.rs index 8b86af6dd..b804d5b28 100644 --- a/tests/generated/flex/align_content_stretch_column.rs +++ b/tests/generated/flex/align_content_stretch_column.rs @@ -6,6 +6,7 @@ fn align_content_stretch_column__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -16,6 +17,10 @@ fn align_content_stretch_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -24,6 +29,7 @@ fn align_content_stretch_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -33,18 +39,21 @@ fn align_content_stretch_column__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -54,6 +63,10 @@ fn align_content_stretch_column__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -68,48 +81,287 @@ fn align_content_stretch_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 150f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node3, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -121,6 +373,7 @@ fn align_content_stretch_column__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -132,6 +385,10 @@ fn align_content_stretch_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -141,6 +398,7 @@ fn align_content_stretch_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -151,6 +409,7 @@ fn align_content_stretch_column__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -158,6 +417,7 @@ fn align_content_stretch_column__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -165,6 +425,7 @@ fn align_content_stretch_column__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -175,6 +436,10 @@ fn align_content_stretch_column__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -189,46 +454,285 @@ fn align_content_stretch_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 150f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node3, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs b/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs index d31013949..7af8e9eab 100644 --- a/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs +++ b/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs @@ -6,6 +6,7 @@ fn align_content_stretch_is_not_overriding_align_items__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_content_stretch_is_not_overriding_align_items__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { @@ -30,7 +35,14 @@ fn align_content_stretch_is_not_overriding_align_items__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_content: Some(taffy::style::AlignContent::Stretch), + ..Default::default() + }, &[node0], ) .unwrap(); @@ -38,24 +50,137 @@ fn align_content_stretch_is_not_overriding_align_items__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +192,7 @@ fn align_content_stretch_is_not_overriding_align_items__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -79,6 +205,10 @@ fn align_content_stretch_is_not_overriding_align_items__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { @@ -94,6 +224,10 @@ fn align_content_stretch_is_not_overriding_align_items__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -104,22 +238,135 @@ fn align_content_stretch_is_not_overriding_align_items__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row.rs b/tests/generated/flex/align_content_stretch_row.rs index 50408da0e..c0d73d3ce 100644 --- a/tests/generated/flex/align_content_stretch_row.rs +++ b/tests/generated/flex/align_content_stretch_row.rs @@ -6,30 +6,35 @@ fn align_content_stretch_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -38,6 +43,10 @@ fn align_content_stretch_row__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -52,42 +61,242 @@ fn align_content_stretch_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +308,7 @@ fn align_content_stretch_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -106,6 +316,7 @@ fn align_content_stretch_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -113,6 +324,7 @@ fn align_content_stretch_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -120,6 +332,7 @@ fn align_content_stretch_row__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -127,6 +340,7 @@ fn align_content_stretch_row__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -136,6 +350,10 @@ fn align_content_stretch_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -150,40 +368,240 @@ fn align_content_stretch_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_children.rs b/tests/generated/flex/align_content_stretch_row_with_children.rs index 097ebeb89..8f45d2f22 100644 --- a/tests/generated/flex/align_content_stretch_row_with_children.rs +++ b/tests/generated/flex/align_content_stretch_row_with_children.rs @@ -6,6 +6,7 @@ fn align_content_stretch_row_with_children__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -16,6 +17,10 @@ fn align_content_stretch_row_with_children__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -24,24 +29,28 @@ fn align_content_stretch_row_with_children__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -50,6 +59,10 @@ fn align_content_stretch_row_with_children__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -64,48 +77,287 @@ fn align_content_stretch_row_with_children__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -117,6 +369,7 @@ fn align_content_stretch_row_with_children__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -128,6 +381,10 @@ fn align_content_stretch_row_with_children__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -137,6 +394,7 @@ fn align_content_stretch_row_with_children__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -144,6 +402,7 @@ fn align_content_stretch_row_with_children__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -151,6 +410,7 @@ fn align_content_stretch_row_with_children__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -158,6 +418,7 @@ fn align_content_stretch_row_with_children__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -167,6 +428,10 @@ fn align_content_stretch_row_with_children__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -181,46 +446,285 @@ fn align_content_stretch_row_with_children__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs b/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs index bf5c96727..1071190d2 100644 --- a/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs +++ b/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_fixed_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -21,18 +23,21 @@ fn align_content_stretch_row_with_fixed_height__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -41,6 +46,10 @@ fn align_content_stretch_row_with_fixed_height__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -55,42 +64,242 @@ fn align_content_stretch_row_with_fixed_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,6 +311,7 @@ fn align_content_stretch_row_with_fixed_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -109,6 +319,7 @@ fn align_content_stretch_row_with_fixed_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -119,6 +330,7 @@ fn align_content_stretch_row_with_fixed_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -126,6 +338,7 @@ fn align_content_stretch_row_with_fixed_height__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -133,6 +346,7 @@ fn align_content_stretch_row_with_fixed_height__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -142,6 +356,10 @@ fn align_content_stretch_row_with_fixed_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -156,40 +374,240 @@ fn align_content_stretch_row_with_fixed_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_flex.rs b/tests/generated/flex/align_content_stretch_row_with_flex.rs index bfdfe44e5..7d8f60577 100644 --- a/tests/generated/flex/align_content_stretch_row_with_flex.rs +++ b/tests/generated/flex/align_content_stretch_row_with_flex.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -21,12 +23,14 @@ fn align_content_stretch_row_with_flex__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -36,6 +40,7 @@ fn align_content_stretch_row_with_flex__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -44,6 +49,10 @@ fn align_content_stretch_row_with_flex__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -58,42 +67,272 @@ fn align_content_stretch_row_with_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -105,6 +344,7 @@ fn align_content_stretch_row_with_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -112,6 +352,7 @@ fn align_content_stretch_row_with_flex__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -122,6 +363,7 @@ fn align_content_stretch_row_with_flex__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -129,6 +371,7 @@ fn align_content_stretch_row_with_flex__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -139,6 +382,7 @@ fn align_content_stretch_row_with_flex__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -148,6 +392,10 @@ fn align_content_stretch_row_with_flex__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -162,40 +410,270 @@ fn align_content_stretch_row_with_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs b/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs index 3eed6ac30..7e4eb964d 100644 --- a/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs +++ b/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_flex_no_shrink__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -21,12 +23,14 @@ fn align_content_stretch_row_with_flex_no_shrink__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -36,6 +40,7 @@ fn align_content_stretch_row_with_flex_no_shrink__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -44,6 +49,10 @@ fn align_content_stretch_row_with_flex_no_shrink__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -58,42 +67,272 @@ fn align_content_stretch_row_with_flex_no_shrink__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -105,6 +344,7 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -112,6 +352,7 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -122,6 +363,7 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -129,6 +371,7 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -139,6 +382,7 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -148,6 +392,10 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -162,40 +410,270 @@ fn align_content_stretch_row_with_flex_no_shrink__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_margin.rs b/tests/generated/flex/align_content_stretch_row_with_margin.rs index 5455979e9..f119f446e 100644 --- a/tests/generated/flex/align_content_stretch_row_with_margin.rs +++ b/tests/generated/flex/align_content_stretch_row_with_margin.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), @@ -24,12 +26,14 @@ fn align_content_stretch_row_with_margin__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), @@ -42,6 +46,7 @@ fn align_content_stretch_row_with_margin__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -50,6 +55,10 @@ fn align_content_stretch_row_with_margin__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -64,42 +73,242 @@ fn align_content_stretch_row_with_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn align_content_stretch_row_with_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -118,6 +328,7 @@ fn align_content_stretch_row_with_margin__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), @@ -131,6 +342,7 @@ fn align_content_stretch_row_with_margin__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -138,6 +350,7 @@ fn align_content_stretch_row_with_margin__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), @@ -151,6 +364,7 @@ fn align_content_stretch_row_with_margin__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -160,6 +374,10 @@ fn align_content_stretch_row_with_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -174,40 +392,240 @@ fn align_content_stretch_row_with_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_max_height.rs b/tests/generated/flex/align_content_stretch_row_with_max_height.rs index 751ef0e36..295992951 100644 --- a/tests/generated/flex/align_content_stretch_row_with_max_height.rs +++ b/tests/generated/flex/align_content_stretch_row_with_max_height.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -19,18 +21,21 @@ fn align_content_stretch_row_with_max_height__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -39,6 +44,10 @@ fn align_content_stretch_row_with_max_height__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -53,42 +62,242 @@ fn align_content_stretch_row_with_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +309,7 @@ fn align_content_stretch_row_with_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -107,6 +317,7 @@ fn align_content_stretch_row_with_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -115,6 +326,7 @@ fn align_content_stretch_row_with_max_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -122,6 +334,7 @@ fn align_content_stretch_row_with_max_height__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -129,6 +342,7 @@ fn align_content_stretch_row_with_max_height__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -138,6 +352,10 @@ fn align_content_stretch_row_with_max_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -152,40 +370,240 @@ fn align_content_stretch_row_with_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_min_height.rs b/tests/generated/flex/align_content_stretch_row_with_min_height.rs index 6f96cb710..feb190d1a 100644 --- a/tests/generated/flex/align_content_stretch_row_with_min_height.rs +++ b/tests/generated/flex/align_content_stretch_row_with_min_height.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, ..Default::default() @@ -19,18 +21,21 @@ fn align_content_stretch_row_with_min_height__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -39,6 +44,10 @@ fn align_content_stretch_row_with_min_height__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -53,42 +62,242 @@ fn align_content_stretch_row_with_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +309,7 @@ fn align_content_stretch_row_with_min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -107,6 +317,7 @@ fn align_content_stretch_row_with_min_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, ..Default::default() @@ -115,6 +326,7 @@ fn align_content_stretch_row_with_min_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -122,6 +334,7 @@ fn align_content_stretch_row_with_min_height__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -129,6 +342,7 @@ fn align_content_stretch_row_with_min_height__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -138,6 +352,10 @@ fn align_content_stretch_row_with_min_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -152,40 +370,240 @@ fn align_content_stretch_row_with_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_padding.rs b/tests/generated/flex/align_content_stretch_row_with_padding.rs index f6c6d7c45..88af1e746 100644 --- a/tests/generated/flex/align_content_stretch_row_with_padding.rs +++ b/tests/generated/flex/align_content_stretch_row_with_padding.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, padding: taffy::geometry::Rect { left: length(10f32), @@ -24,12 +26,14 @@ fn align_content_stretch_row_with_padding__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, padding: taffy::geometry::Rect { left: length(10f32), @@ -42,6 +46,7 @@ fn align_content_stretch_row_with_padding__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -50,6 +55,10 @@ fn align_content_stretch_row_with_padding__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -64,42 +73,242 @@ fn align_content_stretch_row_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn align_content_stretch_row_with_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -118,6 +328,7 @@ fn align_content_stretch_row_with_padding__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, padding: taffy::geometry::Rect { left: length(10f32), @@ -131,6 +342,7 @@ fn align_content_stretch_row_with_padding__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -138,6 +350,7 @@ fn align_content_stretch_row_with_padding__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, padding: taffy::geometry::Rect { left: length(10f32), @@ -151,6 +364,7 @@ fn align_content_stretch_row_with_padding__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -160,6 +374,10 @@ fn align_content_stretch_row_with_padding__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -174,40 +392,240 @@ fn align_content_stretch_row_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node1, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node3, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_with_single_row.rs b/tests/generated/flex/align_content_stretch_row_with_single_row.rs index 13204cf34..eaeb1ab8d 100644 --- a/tests/generated/flex/align_content_stretch_row_with_single_row.rs +++ b/tests/generated/flex/align_content_stretch_row_with_single_row.rs @@ -6,12 +6,14 @@ fn align_content_stretch_row_with_single_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -20,6 +22,10 @@ fn align_content_stretch_row_with_single_row__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -34,24 +40,137 @@ fn align_content_stretch_row_with_single_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +182,7 @@ fn align_content_stretch_row_with_single_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -70,6 +190,7 @@ fn align_content_stretch_row_with_single_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -79,6 +200,10 @@ fn align_content_stretch_row_with_single_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -93,22 +218,135 @@ fn align_content_stretch_row_with_single_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_content_stretch_row_wrap.rs b/tests/generated/flex/align_content_stretch_row_wrap.rs index 24085f0ae..f892a3b65 100644 --- a/tests/generated/flex/align_content_stretch_row_wrap.rs +++ b/tests/generated/flex/align_content_stretch_row_wrap.rs @@ -6,6 +6,7 @@ fn align_content_stretch_row_wrap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(150f32), @@ -16,6 +17,10 @@ fn align_content_stretch_row_wrap__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -26,6 +31,10 @@ fn align_content_stretch_row_wrap__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -40,24 +49,137 @@ fn align_content_stretch_row_wrap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -69,6 +191,7 @@ fn align_content_stretch_row_wrap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(150f32), @@ -80,6 +203,10 @@ fn align_content_stretch_row_wrap__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -91,6 +218,10 @@ fn align_content_stretch_row_wrap__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), @@ -105,22 +236,135 @@ fn align_content_stretch_row_wrap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_flex_start_with_shrinking_children.rs b/tests/generated/flex/align_flex_start_with_shrinking_children.rs index 4b8485186..3934605e7 100644 --- a/tests/generated/flex/align_flex_start_with_shrinking_children.rs +++ b/tests/generated/flex/align_flex_start_with_shrinking_children.rs @@ -4,20 +4,48 @@ fn align_flex_start_with_shrinking_children__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::FlexStart), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -31,30 +59,176 @@ fn align_flex_start_with_shrinking_children__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +240,7 @@ fn align_flex_start_with_shrinking_children__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -75,6 +250,10 @@ fn align_flex_start_with_shrinking_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -86,6 +265,10 @@ fn align_flex_start_with_shrinking_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, @@ -96,6 +279,10 @@ fn align_flex_start_with_shrinking_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -109,28 +296,174 @@ fn align_flex_start_with_shrinking_children__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs b/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs index 816fccbf3..13a471362 100644 --- a/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs +++ b/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs @@ -4,11 +4,21 @@ fn align_flex_start_with_shrinking_children_with_stretch__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), flex_grow: 1f32, flex_shrink: 1f32, @@ -19,13 +29,24 @@ fn align_flex_start_with_shrinking_children_with_stretch__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::FlexStart), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -39,30 +60,176 @@ fn align_flex_start_with_shrinking_children_with_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +241,7 @@ fn align_flex_start_with_shrinking_children_with_stretch__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -83,6 +251,10 @@ fn align_flex_start_with_shrinking_children_with_stretch__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), flex_grow: 1f32, flex_shrink: 1f32, @@ -95,6 +267,10 @@ fn align_flex_start_with_shrinking_children_with_stretch__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, @@ -105,6 +281,10 @@ fn align_flex_start_with_shrinking_children_with_stretch__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -118,28 +298,174 @@ fn align_flex_start_with_shrinking_children_with_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_flex_start_with_stretching_children.rs b/tests/generated/flex/align_flex_start_with_stretching_children.rs index 26a533fb5..bdca009cb 100644 --- a/tests/generated/flex/align_flex_start_with_stretching_children.rs +++ b/tests/generated/flex/align_flex_start_with_stretching_children.rs @@ -4,20 +4,48 @@ fn align_flex_start_with_stretching_children__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::Stretch), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::Stretch), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -31,30 +59,182 @@ fn align_flex_start_with_stretching_children__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node00, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node000, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +246,7 @@ fn align_flex_start_with_stretching_children__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -75,6 +256,10 @@ fn align_flex_start_with_stretching_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -86,6 +271,10 @@ fn align_flex_start_with_stretching_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), ..Default::default() }, @@ -96,6 +285,10 @@ fn align_flex_start_with_stretching_children__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -109,28 +302,180 @@ fn align_flex_start_with_stretching_children__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node00, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node000, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center.rs b/tests/generated/flex/align_items_center.rs index ef2c7528b..b324bd540 100644 --- a/tests/generated/flex/align_items_center.rs +++ b/tests/generated/flex/align_items_center.rs @@ -6,6 +6,7 @@ fn align_items_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn align_items_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_items_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_items_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -64,6 +138,10 @@ fn align_items_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_items_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs b/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs index 700d54ea4..5c4daca6b 100644 --- a/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn align_items_center_child_with_margin_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -16,13 +17,24 @@ fn align_items_center_child_with_margin_bigger_than_parent__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::Center), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -38,24 +50,131 @@ fn align_items_center_child_with_margin_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +186,7 @@ fn align_items_center_child_with_margin_bigger_than_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +199,10 @@ fn align_items_center_child_with_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, @@ -89,6 +213,10 @@ fn align_items_center_child_with_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -104,22 +232,129 @@ fn align_items_center_child_with_margin_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs b/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs index ec673c7c7..dfb467b9f 100644 --- a/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn align_items_center_child_without_margin_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(70f32), @@ -15,13 +16,24 @@ fn align_items_center_child_without_margin_bigger_than_parent__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::Center), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -37,24 +49,131 @@ fn align_items_center_child_without_margin_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 70f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn align_items_center_child_without_margin_bigger_than_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(70f32), @@ -77,6 +197,10 @@ fn align_items_center_child_without_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, @@ -87,6 +211,10 @@ fn align_items_center_child_without_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -102,22 +230,129 @@ fn align_items_center_child_without_margin_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 70f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_justify_content_center.rs b/tests/generated/flex/align_items_center_justify_content_center.rs index 40ec5d62d..9d2df2cc7 100644 --- a/tests/generated/flex/align_items_center_justify_content_center.rs +++ b/tests/generated/flex/align_items_center_justify_content_center.rs @@ -7,6 +7,10 @@ fn align_items_center_justify_content_center__border_box() { let node000 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -20,6 +24,10 @@ fn align_items_center_justify_content_center__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, @@ -38,6 +46,10 @@ fn align_items_center_justify_content_center__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, @@ -50,6 +62,10 @@ fn align_items_center_justify_content_center__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -63,30 +79,176 @@ fn align_items_center_justify_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node0, 500f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 245f32, "x of node {:?}. Expected {}. Actual {}", node00, 245f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 245f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 245f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node000, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +261,10 @@ fn align_items_center_justify_content_center__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -113,6 +279,10 @@ fn align_items_center_justify_content_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, @@ -132,6 +302,10 @@ fn align_items_center_justify_content_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, @@ -145,6 +319,10 @@ fn align_items_center_justify_content_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -158,28 +336,174 @@ fn align_items_center_justify_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node0, 500f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 245f32, "x of node {:?}. Expected {}. Actual {}", node00, 245f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 245f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 245f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node000, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_min_max_with_padding.rs b/tests/generated/flex/align_items_center_min_max_with_padding.rs index e33f72e21..41c6c450f 100644 --- a/tests/generated/flex/align_items_center_min_max_with_padding.rs +++ b/tests/generated/flex/align_items_center_min_max_with_padding.rs @@ -6,6 +6,7 @@ fn align_items_center_min_max_with_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(62f32), height: taffy::style::Dimension::from_length(62f32), @@ -16,6 +17,10 @@ fn align_items_center_min_max_with_padding__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), @@ -35,18 +40,86 @@ fn align_items_center_min_max_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 78f32, "height of node {:?}. Expected {}. Actual {}", node, 78f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 78f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node0, 62f32, size.width); - assert_eq!(size.height, 62f32, "height of node {:?}. Expected {}. Actual {}", node0, 62f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 62f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +131,7 @@ fn align_items_center_min_max_with_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(62f32), height: taffy::style::Dimension::from_length(62f32), @@ -69,6 +143,10 @@ fn align_items_center_min_max_with_padding__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), @@ -88,16 +166,84 @@ fn align_items_center_min_max_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 88f32, "height of node {:?}. Expected {}. Actual {}", node, 88f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 88f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node0, 62f32, size.width); - assert_eq!(size.height, 62f32, "height of node {:?}. Expected {}. Actual {}", node0, 62f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 62f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_child_margin.rs b/tests/generated/flex/align_items_center_with_child_margin.rs index 65ed8f5c4..23f3ea611 100644 --- a/tests/generated/flex/align_items_center_with_child_margin.rs +++ b/tests/generated/flex/align_items_center_with_child_margin.rs @@ -6,6 +6,7 @@ fn align_items_center_with_child_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_items_center_with_child_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_items_center_with_child_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_items_center_with_child_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_items_center_with_child_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_items_center_with_child_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_child_top.rs b/tests/generated/flex/align_items_center_with_child_top.rs index c4fa378e0..49f64aa8b 100644 --- a/tests/generated/flex/align_items_center_with_child_top.rs +++ b/tests/generated/flex/align_items_center_with_child_top.rs @@ -6,6 +6,7 @@ fn align_items_center_with_child_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_items_center_with_child_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_items_center_with_child_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node0, 55f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_items_center_with_child_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_items_center_with_child_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_items_center_with_child_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node0, 55f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs b/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs index f6aae6368..f6f1aeaf0 100644 --- a/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs +++ b/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs @@ -6,6 +6,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -27,6 +29,10 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { @@ -40,6 +46,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -49,6 +56,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -61,6 +69,10 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -71,53 +83,333 @@ fn align_items_center_with_height_with_padding_border_with_wrap__border_box() { &[node10, node11], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +421,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -139,6 +432,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -152,6 +446,10 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { @@ -166,6 +464,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -176,6 +475,7 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -189,6 +489,10 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -201,7 +505,14 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -209,46 +520,315 @@ fn align_items_center_with_height_with_padding_border_with_wrap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs index 0b7acbe17..4cc92e9fe 100644 --- a/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs +++ b/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs @@ -6,6 +6,7 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,10 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { @@ -44,6 +50,10 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -57,30 +67,176 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node01, 15f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -92,6 +248,7 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -102,6 +259,7 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -114,6 +272,10 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { @@ -133,6 +295,10 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -146,28 +312,174 @@ fn align_items_center_with_max_height_percentage_with_align_content_flex_start__ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node01, 15f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs index 61d5d9ea8..c0f18b9c6 100644 --- a/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs +++ b/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs @@ -6,6 +6,7 @@ fn align_items_center_with_max_height_with_align_content_flex_start__border_box( let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn align_items_center_with_max_height_with_align_content_flex_start__border_box( .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -25,6 +27,10 @@ fn align_items_center_with_max_height_with_align_content_flex_start__border_box( let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -38,24 +44,131 @@ fn align_items_center_with_max_height_with_align_content_flex_start__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node1, -25f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +180,7 @@ fn align_items_center_with_max_height_with_align_content_flex_start__content_box let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(50f32), @@ -77,6 +191,7 @@ fn align_items_center_with_max_height_with_align_content_flex_start__content_box let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -88,6 +203,10 @@ fn align_items_center_with_max_height_with_align_content_flex_start__content_box .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -101,22 +220,129 @@ fn align_items_center_with_max_height_with_align_content_flex_start__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node1, -25f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs b/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs index 5021dd546..fe468742e 100644 --- a/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs +++ b/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs @@ -6,6 +6,7 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -26,6 +28,10 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -49,6 +55,7 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -58,6 +65,7 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -70,6 +78,10 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -93,7 +105,14 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -101,48 +120,317 @@ fn align_items_center_with_max_height_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 35f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 35f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node01, 150f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node01, -25f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 80f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node10, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node11, 150f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node11, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -154,6 +442,7 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -164,6 +453,7 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -176,6 +466,10 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -200,6 +494,7 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -210,6 +505,7 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(150f32), @@ -223,6 +519,10 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -249,6 +549,10 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -258,46 +562,315 @@ fn align_items_center_with_max_height_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 280f32, "height of node {:?}. Expected {}. Actual {}", node, 280f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 280f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 280f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 30f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node00, 65f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node01, 150f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node1, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node1, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node1, 140f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node10, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node11, 150f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node11, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs index 2c8856d9c..a6a6fc517 100644 --- a/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs +++ b/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs @@ -6,6 +6,7 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,10 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -38,6 +44,10 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -51,30 +61,182 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +248,7 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -96,6 +259,7 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -108,6 +272,10 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -121,6 +289,10 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -134,28 +306,180 @@ fn align_items_center_with_min_height_percentage_with_align_content_flex_start__ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs index 0e629fd1e..1a77e8aec 100644 --- a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs +++ b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs @@ -6,6 +6,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start__border_box( let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start__border_box( .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -25,6 +27,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start__border_box( let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -38,24 +44,125 @@ fn align_items_center_with_min_height_with_align_content_flex_start__border_box( println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +174,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start__content_box let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -77,6 +185,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start__content_box let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -88,6 +197,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start__content_box .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -101,22 +214,123 @@ fn align_items_center_with_min_height_with_align_content_flex_start__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs index f1269b748..724eb4564 100644 --- a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs +++ b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs @@ -6,6 +6,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -27,6 +29,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -38,6 +44,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -47,6 +54,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -59,6 +67,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -69,6 +81,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -78,6 +91,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node21 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +103,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -99,6 +117,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node30 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -108,6 +127,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .unwrap(); let node31 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -119,6 +139,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -128,90 +152,603 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__b &[node30, node31], ) .unwrap(); - let node = - taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1, node2, node3]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node2, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node20, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node21, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node21, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node21, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node21, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node3, 300f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node30).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node30, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node30, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node31).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node31, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node31, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node31, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node31, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -223,6 +760,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -233,6 +771,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -246,6 +785,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -258,6 +801,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -268,6 +812,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -281,6 +826,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -292,6 +841,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -302,6 +852,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node21 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -314,6 +865,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -325,6 +880,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node30 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -335,6 +891,7 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c let node31 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -347,6 +904,10 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -358,7 +919,14 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1, node2, node3], ) .unwrap(); @@ -366,82 +934,585 @@ fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap__c println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node2, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node20, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node21, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node21, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node21, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node21, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node3, 300f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node30).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node30, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node30, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node31).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node31, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node31, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node31, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node31, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs b/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs index d6fb81b33..20f4c210e 100644 --- a/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs +++ b/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs @@ -6,6 +6,7 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,10 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -49,6 +55,7 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -58,6 +65,7 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -70,6 +78,10 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -91,53 +103,333 @@ fn align_items_center_with_min_height_with_padding_border__border_box() { &[node10, node11], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node01, 25f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node10, 15f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node11, 15f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -149,6 +441,7 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -159,6 +452,7 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -171,6 +465,10 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -195,6 +493,7 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -205,6 +504,7 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(20f32), @@ -218,6 +518,10 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -241,7 +545,14 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -249,46 +560,315 @@ fn align_items_center_with_min_height_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node, 260f32, size.width); - assert_eq!(size.height, 130f32, "height of node {:?}. Expected {}. Actual {}", node, 130f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 260f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 260f32, layout.size.width); + } + if layout.size.height != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 130f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); - assert_eq!(size.height, 130f32, "height of node {:?}. Expected {}. Actual {}", node0, 130f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 130f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 130f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node00, 60f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node01, 25f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node01, 55f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node1, 130f32, size.width); - assert_eq!(size.height, 130f32, "height of node {:?}. Expected {}. Actual {}", node1, 130f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node1, 130f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 130f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 130f32, + layout.size.height + ); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node10, 15f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node11, 15f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_flex_end.rs b/tests/generated/flex/align_items_flex_end.rs index 759f295f1..3778d92ee 100644 --- a/tests/generated/flex/align_items_flex_end.rs +++ b/tests/generated/flex/align_items_flex_end.rs @@ -6,6 +6,7 @@ fn align_items_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn align_items_flex_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_items_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_items_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -64,6 +138,10 @@ fn align_items_flex_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_items_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs index 1586435e1..da202cd23 100644 --- a/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -16,13 +17,24 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::FlexEnd), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -38,24 +50,131 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +186,7 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -79,6 +199,10 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, @@ -89,6 +213,10 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -104,22 +232,129 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs index d67de9206..b40e18f65 100644 --- a/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(70f32), @@ -15,13 +16,24 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::FlexEnd), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -37,24 +49,131 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 70f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(70f32), @@ -77,6 +197,10 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, @@ -87,6 +211,10 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -102,22 +230,129 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 70f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_flex_start.rs b/tests/generated/flex/align_items_flex_start.rs index 7a15c2fb7..6eb4274f1 100644 --- a/tests/generated/flex/align_items_flex_start.rs +++ b/tests/generated/flex/align_items_flex_start.rs @@ -6,6 +6,7 @@ fn align_items_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn align_items_flex_start__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_items_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_items_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -64,6 +138,10 @@ fn align_items_flex_start__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_items_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_min_max.rs b/tests/generated/flex/align_items_min_max.rs index 33b0dac35..0e1416f48 100644 --- a/tests/generated/flex/align_items_min_max.rs +++ b/tests/generated/flex/align_items_min_max.rs @@ -6,6 +6,7 @@ fn align_items_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,10 @@ fn align_items_min_max__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -30,18 +35,86 @@ fn align_items_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_items_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(60f32), @@ -65,6 +139,10 @@ fn align_items_min_max__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -78,16 +156,84 @@ fn align_items_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_stretch.rs b/tests/generated/flex/align_items_stretch.rs index 6f273217c..322a59029 100644 --- a/tests/generated/flex/align_items_stretch.rs +++ b/tests/generated/flex/align_items_stretch.rs @@ -6,6 +6,7 @@ fn align_items_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -13,6 +14,10 @@ fn align_items_stretch__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -26,18 +31,92 @@ fn align_items_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,6 +128,7 @@ fn align_items_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -57,6 +137,10 @@ fn align_items_stretch__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -70,16 +154,90 @@ fn align_items_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_items_stretch_min_cross.rs b/tests/generated/flex/align_items_stretch_min_cross.rs index c20887469..be76b17fd 100644 --- a/tests/generated/flex/align_items_stretch_min_cross.rs +++ b/tests/generated/flex/align_items_stretch_min_cross.rs @@ -6,6 +6,7 @@ fn align_items_stretch_min_cross__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(36f32) }, ..Default::default() @@ -15,6 +16,10 @@ fn align_items_stretch_min_cross__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(50f32), @@ -28,18 +33,86 @@ fn align_items_stretch_min_cross__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node0, 400f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node0, 36f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn align_items_stretch_min_cross__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(36f32) }, ..Default::default() @@ -61,6 +135,10 @@ fn align_items_stretch_min_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(50f32), @@ -74,16 +152,84 @@ fn align_items_stretch_min_cross__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node0, 400f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node0, 36f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_baseline.rs b/tests/generated/flex/align_self_baseline.rs index e7365e272..9aaae6ae9 100644 --- a/tests/generated/flex/align_self_baseline.rs +++ b/tests/generated/flex/align_self_baseline.rs @@ -6,6 +6,7 @@ fn align_self_baseline__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -16,6 +17,7 @@ fn align_self_baseline__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn align_self_baseline__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -39,6 +45,10 @@ fn align_self_baseline__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -52,30 +62,170 @@ fn align_self_baseline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +237,7 @@ fn align_self_baseline__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -98,6 +249,7 @@ fn align_self_baseline__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -109,6 +261,10 @@ fn align_self_baseline__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -123,6 +279,10 @@ fn align_self_baseline__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -136,28 +296,168 @@ fn align_self_baseline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_center.rs b/tests/generated/flex/align_self_center.rs index 357446266..4b6068381 100644 --- a/tests/generated/flex/align_self_center.rs +++ b/tests/generated/flex/align_self_center.rs @@ -6,6 +6,7 @@ fn align_self_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_self_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_self_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_self_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -65,6 +139,10 @@ fn align_self_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_self_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_center_undefined_max_height.rs b/tests/generated/flex/align_self_center_undefined_max_height.rs index 19da963d6..f340d1d87 100644 --- a/tests/generated/flex/align_self_center_undefined_max_height.rs +++ b/tests/generated/flex/align_self_center_undefined_max_height.rs @@ -6,6 +6,7 @@ fn align_self_center_undefined_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(44f32), @@ -15,6 +16,7 @@ fn align_self_center_undefined_max_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -26,6 +28,10 @@ fn align_self_center_undefined_max_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(280f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(52f32) }, ..Default::default() @@ -37,24 +43,125 @@ fn align_self_center_undefined_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 280f32, "width of node {:?}. Expected {}. Actual {}", node, 280f32, size.width); - assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node, 56f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 280f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 280f32, layout.size.width); + } + if layout.size.height != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 56f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node0, 240f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node1, 56f32, size.height); - assert_eq!(location.x, 240f32, "x of node {:?}. Expected {}. Actual {}", node1, 240f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 56f32, layout.size.height); + } + if layout.location.x != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 240f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +173,7 @@ fn align_self_center_undefined_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(44f32), @@ -76,6 +184,7 @@ fn align_self_center_undefined_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -88,6 +197,10 @@ fn align_self_center_undefined_max_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(280f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(52f32) }, ..Default::default() @@ -99,22 +212,123 @@ fn align_self_center_undefined_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 280f32, "width of node {:?}. Expected {}. Actual {}", node, 280f32, size.width); - assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node, 56f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 280f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 280f32, layout.size.width); + } + if layout.size.height != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 56f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node0, 240f32, size.width); - assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 44f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node1, 56f32, size.height); - assert_eq!(location.x, 240f32, "x of node {:?}. Expected {}. Actual {}", node1, 240f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 56f32, layout.size.height); + } + if layout.location.x != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 240f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_flex_end.rs b/tests/generated/flex/align_self_flex_end.rs index 109787b4a..ced2484f5 100644 --- a/tests/generated/flex/align_self_flex_end.rs +++ b/tests/generated/flex/align_self_flex_end.rs @@ -6,6 +6,7 @@ fn align_self_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_self_flex_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_self_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_self_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -65,6 +139,10 @@ fn align_self_flex_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_self_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_flex_end_override_flex_start.rs b/tests/generated/flex/align_self_flex_end_override_flex_start.rs index 72648384e..bb6d132e9 100644 --- a/tests/generated/flex/align_self_flex_end_override_flex_start.rs +++ b/tests/generated/flex/align_self_flex_end_override_flex_start.rs @@ -6,6 +6,7 @@ fn align_self_flex_end_override_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_self_flex_end_override_flex_start__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn align_self_flex_end_override_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn align_self_flex_end_override_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -66,6 +140,10 @@ fn align_self_flex_end_override_flex_start__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn align_self_flex_end_override_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_self_flex_start.rs b/tests/generated/flex/align_self_flex_start.rs index 04a865c37..dbade17d0 100644 --- a/tests/generated/flex/align_self_flex_start.rs +++ b/tests/generated/flex/align_self_flex_start.rs @@ -6,6 +6,7 @@ fn align_self_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn align_self_flex_start__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn align_self_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn align_self_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -65,6 +139,10 @@ fn align_self_flex_start__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn align_self_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/align_stretch_should_size_based_on_parent.rs b/tests/generated/flex/align_stretch_should_size_based_on_parent.rs index 20d8a28ab..d0bf76023 100644 --- a/tests/generated/flex/align_stretch_should_size_based_on_parent.rs +++ b/tests/generated/flex/align_stretch_should_size_based_on_parent.rs @@ -6,6 +6,7 @@ fn align_stretch_should_size_based_on_parent__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -14,11 +15,26 @@ fn align_stretch_should_size_based_on_parent__border_box() { }) .unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, @@ -30,6 +46,10 @@ fn align_stretch_should_size_based_on_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -43,30 +63,182 @@ fn align_stretch_should_size_based_on_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +250,7 @@ fn align_stretch_should_size_based_on_parent__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +262,10 @@ fn align_stretch_should_size_based_on_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -100,6 +277,10 @@ fn align_stretch_should_size_based_on_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, @@ -112,6 +293,10 @@ fn align_stretch_should_size_based_on_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -125,28 +310,180 @@ fn align_stretch_should_size_based_on_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/android_news_feed.rs b/tests/generated/flex/android_news_feed.rs index 29ec8e9f7..029bc9bc2 100644 --- a/tests/generated/flex/android_news_feed.rs +++ b/tests/generated/flex/android_news_feed.rs @@ -6,6 +6,7 @@ fn android_news_feed__border_box() { let mut taffy = crate::new_test_tree(); let node000000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { @@ -18,6 +19,10 @@ fn android_news_feed__border_box() { let node00000 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() @@ -27,6 +32,7 @@ fn android_news_feed__border_box() { .unwrap(); let node000010 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -34,6 +40,7 @@ fn android_news_feed__border_box() { .unwrap(); let node000011 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -43,6 +50,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(36f32), top: zero(), bottom: zero() }, @@ -60,6 +71,10 @@ fn android_news_feed__border_box() { let node0000 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { @@ -77,6 +92,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -85,6 +104,7 @@ fn android_news_feed__border_box() { .unwrap(); let node001000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { @@ -97,6 +117,10 @@ fn android_news_feed__border_box() { let node00100 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() @@ -106,6 +130,7 @@ fn android_news_feed__border_box() { .unwrap(); let node001010 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -113,6 +138,7 @@ fn android_news_feed__border_box() { .unwrap(); let node001011 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -122,6 +148,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(36f32), top: zero(), bottom: zero() }, @@ -139,6 +169,10 @@ fn android_news_feed__border_box() { let node0010 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { @@ -156,6 +190,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -166,6 +204,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -176,6 +218,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_shrink: 0f32, ..Default::default() }, @@ -186,6 +232,10 @@ fn android_news_feed__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1080f32), height: auto() }, @@ -198,108 +248,1007 @@ fn android_news_feed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node00, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node00, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node000, 1080f32, size.width); - assert_eq!(size.height, 144f32, "height of node {:?}. Expected {}. Actual {}", node000, 144f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 144f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 144f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1044f32, "width of node {:?}. Expected {}. Actual {}", node0000, 1044f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0000, 120f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node0000, 36f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0000, 24f32, location.y); + if layout.size.width != 1044f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 1044f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(location.y), + 24f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(size.width), + 120f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(size.width), + 120f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00001, 72f32, size.width); - assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00001, 39f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node00001, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00001, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 39f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(size.height), + 39f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(location.x), + 120f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000010, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000010, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000011, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000011, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node001, 1080f32, size.width); - assert_eq!(size.height, 96f32, "height of node {:?}. Expected {}. Actual {}", node001, 96f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001, 0f32, location.x); - assert_eq!(location.y, 144f32, "y of node {:?}. Expected {}. Actual {}", node001, 144f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 96f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 96f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 144f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(location.y), + 144f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 906f32, "width of node {:?}. Expected {}. Actual {}", node0010, 906f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0010, 72f32, size.height); - assert_eq!(location.x, 174f32, "x of node {:?}. Expected {}. Actual {}", node0010, 174f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0010, 24f32, location.y); + if layout.size.width != 906f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.width), + 906f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 174f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(location.x), + 174f32, + layout.location.x + ); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(location.y), + 24f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00101, 72f32, size.width); - assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00101, 39f32, size.height); - assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node00101, 72f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 39f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.height), + 39f32, + layout.size.height + ); + } + if layout.location.x != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.x), + 72f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001010, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001010, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001011, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001011, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -311,6 +1260,7 @@ fn android_news_feed__content_box() { let node000000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { @@ -324,6 +1274,10 @@ fn android_news_feed__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() @@ -334,6 +1288,7 @@ fn android_news_feed__content_box() { let node000010 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -342,6 +1297,7 @@ fn android_news_feed__content_box() { let node000011 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -352,6 +1308,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(36f32), top: zero(), bottom: zero() }, @@ -370,6 +1330,10 @@ fn android_news_feed__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { @@ -388,6 +1352,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -397,6 +1365,7 @@ fn android_news_feed__content_box() { let node001000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { @@ -410,6 +1379,10 @@ fn android_news_feed__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() @@ -420,6 +1393,7 @@ fn android_news_feed__content_box() { let node001010 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -428,6 +1402,7 @@ fn android_news_feed__content_box() { let node001011 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() @@ -438,6 +1413,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(36f32), top: zero(), bottom: zero() }, @@ -456,6 +1435,10 @@ fn android_news_feed__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { @@ -474,6 +1457,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -485,6 +1472,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -496,6 +1487,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_shrink: 0f32, ..Default::default() }, @@ -507,6 +1502,10 @@ fn android_news_feed__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1080f32), height: auto() }, @@ -519,106 +1518,1005 @@ fn android_news_feed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node00, 1080f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node00, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node000, 1080f32, size.width); - assert_eq!(size.height, 144f32, "height of node {:?}. Expected {}. Actual {}", node000, 144f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 144f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 144f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1044f32, "width of node {:?}. Expected {}. Actual {}", node0000, 1044f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0000, 120f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node0000, 36f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0000, 24f32, location.y); + if layout.size.width != 1044f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.width), + 1044f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(location.y), + 24f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(size.width), + 120f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(size.width), + 120f32, + layout.size.width + ); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00001, 72f32, size.width); - assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00001, 39f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node00001, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00001, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 39f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(size.height), + 39f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(location.x), + 120f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000010, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000010, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000011, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000011, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node001, 1080f32, size.width); - assert_eq!(size.height, 96f32, "height of node {:?}. Expected {}. Actual {}", node001, 96f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001, 0f32, location.x); - assert_eq!(location.y, 144f32, "y of node {:?}. Expected {}. Actual {}", node001, 144f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.width), + 1080f32, + layout.size.width + ); + } + if layout.size.height != 96f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 96f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 144f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(location.y), + 144f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 906f32, "width of node {:?}. Expected {}. Actual {}", node0010, 906f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0010, 72f32, size.height); - assert_eq!(location.x, 174f32, "x of node {:?}. Expected {}. Actual {}", node0010, 174f32, location.x); - assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0010, 24f32, location.y); + if layout.size.width != 906f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.width), + 906f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 174f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(location.x), + 174f32, + layout.location.x + ); + } + if layout.location.y != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(location.y), + 24f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(size.height), + 72f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00101, 72f32, size.width); - assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00101, 39f32, size.height); - assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node00101, 72f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.width), + 72f32, + layout.size.width + ); + } + if layout.size.height != 39f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.height), + 39f32, + layout.size.height + ); + } + if layout.location.x != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.x), + 72f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001010, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001010, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001011, 36f32, location.x); - assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001011, 21f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(size.width), + 0f32, + layout.size.width + ); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(location.x), + 36f32, + layout.location.x + ); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(location.y), + 21f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs index fbd4af51c..d22ad52e6 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_fill_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_fill_height__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn aspect_ratio_flex_column_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn aspect_ratio_flex_column_fill_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -64,6 +138,10 @@ fn aspect_ratio_flex_column_fill_height__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn aspect_ratio_flex_column_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs index 6bbf075ce..5fa7cf111 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs @@ -4,12 +4,31 @@ fn aspect_ratio_flex_column_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -24,18 +43,86 @@ fn aspect_ratio_flex_column_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -44,13 +131,33 @@ fn aspect_ratio_flex_column_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -65,16 +172,84 @@ fn aspect_ratio_flex_column_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs index 69c8219b3..da21b6c50 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_column_fill_max_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -19,6 +23,10 @@ fn aspect_ratio_flex_column_fill_max_width__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -33,18 +41,86 @@ fn aspect_ratio_flex_column_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +133,10 @@ fn aspect_ratio_flex_column_fill_max_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -70,6 +150,10 @@ fn aspect_ratio_flex_column_fill_max_width__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -84,16 +168,84 @@ fn aspect_ratio_flex_column_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs index 1eb59377a..9e27d3329 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_fill_min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_fill_min_height__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn aspect_ratio_flex_column_fill_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn aspect_ratio_flex_column_fill_min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -64,6 +138,10 @@ fn aspect_ratio_flex_column_fill_min_height__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn aspect_ratio_flex_column_fill_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs index 8b32b4af3..77c3850f6 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_column_fill_min_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -19,6 +23,10 @@ fn aspect_ratio_flex_column_fill_min_width__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -33,18 +41,86 @@ fn aspect_ratio_flex_column_fill_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +133,10 @@ fn aspect_ratio_flex_column_fill_min_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -70,6 +150,10 @@ fn aspect_ratio_flex_column_fill_min_width__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -84,16 +168,84 @@ fn aspect_ratio_flex_column_fill_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs index 6c0ed5ef8..c7ea6e08c 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_fill_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_fill_width__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -30,18 +35,86 @@ fn aspect_ratio_flex_column_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn aspect_ratio_flex_column_fill_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -64,6 +138,10 @@ fn aspect_ratio_flex_column_fill_width__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -78,16 +156,84 @@ fn aspect_ratio_flex_column_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs b/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs index 85bc74e8d..daa640ee8 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_fill_width_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_fill_width_flex__border_box() { taffy::style::Style { display: taffy::style::Display::Grid, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_column_fill_width_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_column_fill_width_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn aspect_ratio_flex_column_fill_width_flex__content_box() { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_column_fill_width_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs index b51b1083e..c4643404a 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_stretch_fill_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_stretch_fill_height__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_column_stretch_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_column_stretch_fill_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn aspect_ratio_flex_column_stretch_fill_height__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_column_stretch_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs index aaf8d738a..21c43688e 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs @@ -4,12 +4,31 @@ fn aspect_ratio_flex_column_stretch_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -23,18 +42,86 @@ fn aspect_ratio_flex_column_stretch_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -43,13 +130,33 @@ fn aspect_ratio_flex_column_stretch_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -63,16 +170,84 @@ fn aspect_ratio_flex_column_stretch_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs index cbc59d47d..c2812e3ef 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -19,6 +23,10 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +40,86 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +132,10 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -69,6 +149,10 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,84 @@ fn aspect_ratio_flex_column_stretch_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs index 5d617888d..227743fca 100644 --- a/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_column_stretch_fill_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -16,6 +17,10 @@ fn aspect_ratio_flex_column_stretch_fill_width__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_column_stretch_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_column_stretch_fill_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -63,6 +137,10 @@ fn aspect_ratio_flex_column_stretch_fill_width__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_column_stretch_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs index 8e518a1a4..9cec09958 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_fill_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_fill_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_row_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_row_fill_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -62,6 +136,10 @@ fn aspect_ratio_flex_row_fill_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_row_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs index 0d390d579..27e4f6645 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs @@ -4,11 +4,30 @@ fn aspect_ratio_flex_row_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -23,18 +42,86 @@ fn aspect_ratio_flex_row_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -43,12 +130,32 @@ fn aspect_ratio_flex_row_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -63,16 +170,84 @@ fn aspect_ratio_flex_row_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs index 10c2271e7..6b1cd045c 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_row_fill_max_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -18,6 +22,10 @@ fn aspect_ratio_flex_row_fill_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -32,18 +40,86 @@ fn aspect_ratio_flex_row_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +132,10 @@ fn aspect_ratio_flex_row_fill_max_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -68,6 +148,10 @@ fn aspect_ratio_flex_row_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,84 @@ fn aspect_ratio_flex_row_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs index 306fd109e..9d978dc17 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_fill_min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_fill_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_row_fill_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_row_fill_min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -62,6 +136,10 @@ fn aspect_ratio_flex_row_fill_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_row_fill_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs index 120c99d6c..ef6b8d7bf 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_row_fill_min_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -18,6 +22,10 @@ fn aspect_ratio_flex_row_fill_min_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -32,18 +40,86 @@ fn aspect_ratio_flex_row_fill_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +132,10 @@ fn aspect_ratio_flex_row_fill_min_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -68,6 +148,10 @@ fn aspect_ratio_flex_row_fill_min_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,84 @@ fn aspect_ratio_flex_row_fill_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs index 5ad0e7b6c..227cdd364 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_fill_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_fill_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_row_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_row_fill_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -62,6 +136,10 @@ fn aspect_ratio_flex_row_fill_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_row_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs b/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs index 95b9f96c9..be4079147 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_fill_width_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_fill_width_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn aspect_ratio_flex_row_fill_width_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn aspect_ratio_flex_row_fill_width_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -62,6 +136,10 @@ fn aspect_ratio_flex_row_fill_width_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn aspect_ratio_flex_row_fill_width_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs index ee5f21bc2..733ce2b89 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_stretch_fill_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_stretch_fill_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,92 @@ fn aspect_ratio_flex_row_stretch_fill_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +130,7 @@ fn aspect_ratio_flex_row_stretch_fill_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -61,6 +141,10 @@ fn aspect_ratio_flex_row_stretch_fill_height__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +158,90 @@ fn aspect_ratio_flex_row_stretch_fill_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs index f817b405c..031731e52 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs @@ -4,11 +4,30 @@ fn aspect_ratio_flex_row_stretch_fill_max_height__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -22,18 +41,92 @@ fn aspect_ratio_flex_row_stretch_fill_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,12 +135,32 @@ fn aspect_ratio_flex_row_stretch_fill_max_height__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = + "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -61,16 +174,90 @@ fn aspect_ratio_flex_row_stretch_fill_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs index f13106260..0360b84f4 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs @@ -7,6 +7,10 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -18,6 +22,10 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +39,86 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +131,10 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -67,6 +147,10 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +164,84 @@ fn aspect_ratio_flex_row_stretch_fill_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs index 849bd3482..c0aa156c6 100644 --- a/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs +++ b/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs @@ -6,6 +6,7 @@ fn aspect_ratio_flex_row_stretch_fill_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn aspect_ratio_flex_row_stretch_fill_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn aspect_ratio_flex_row_stretch_fill_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn aspect_ratio_flex_row_stretch_fill_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -61,6 +135,10 @@ fn aspect_ratio_flex_row_stretch_fill_width__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn aspect_ratio_flex_row_stretch_fill_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_10343_block.rs b/tests/generated/flex/bevy_issue_10343_block.rs index b4b46d9a1..d0e4f3970 100644 --- a/tests/generated/flex/bevy_issue_10343_block.rs +++ b/tests/generated/flex/bevy_issue_10343_block.rs @@ -4,11 +4,20 @@ fn bevy_issue_10343_block__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -26,7 +35,14 @@ fn bevy_issue_10343_block__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -35,6 +51,10 @@ fn bevy_issue_10343_block__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -49,30 +69,182 @@ fn bevy_issue_10343_block__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000, 90f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,13 +254,21 @@ fn bevy_issue_10343_block__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -109,6 +289,10 @@ fn bevy_issue_10343_block__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -120,6 +304,10 @@ fn bevy_issue_10343_block__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -134,28 +322,180 @@ fn bevy_issue_10343_block__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000, 90f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 0f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_10343_flex.rs b/tests/generated/flex/bevy_issue_10343_flex.rs index b65aa9208..663cac392 100644 --- a/tests/generated/flex/bevy_issue_10343_flex.rs +++ b/tests/generated/flex/bevy_issue_10343_flex.rs @@ -4,11 +4,20 @@ fn bevy_issue_10343_flex__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -26,7 +35,14 @@ fn bevy_issue_10343_flex__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -35,6 +51,10 @@ fn bevy_issue_10343_flex__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -49,30 +69,182 @@ fn bevy_issue_10343_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,13 +254,21 @@ fn bevy_issue_10343_flex__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -109,6 +289,10 @@ fn bevy_issue_10343_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -120,6 +304,10 @@ fn bevy_issue_10343_flex__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -134,28 +322,180 @@ fn bevy_issue_10343_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_10343_grid.rs b/tests/generated/flex/bevy_issue_10343_grid.rs index bd25700ff..f1c867e82 100644 --- a/tests/generated/flex/bevy_issue_10343_grid.rs +++ b/tests/generated/flex/bevy_issue_10343_grid.rs @@ -4,11 +4,20 @@ fn bevy_issue_10343_grid__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -26,7 +35,14 @@ fn bevy_issue_10343_grid__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -35,6 +51,10 @@ fn bevy_issue_10343_grid__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -49,30 +69,182 @@ fn bevy_issue_10343_grid__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,13 +254,21 @@ fn bevy_issue_10343_grid__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -109,6 +289,10 @@ fn bevy_issue_10343_grid__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -120,6 +304,10 @@ fn bevy_issue_10343_grid__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -134,28 +322,180 @@ fn bevy_issue_10343_grid__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 110f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 110f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000, 90f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_16304.rs b/tests/generated/flex/bevy_issue_16304.rs index 6fbf53dbb..cef2bca70 100644 --- a/tests/generated/flex/bevy_issue_16304.rs +++ b/tests/generated/flex/bevy_issue_16304.rs @@ -6,6 +6,7 @@ fn bevy_issue_16304__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -15,6 +16,7 @@ fn bevy_issue_16304__border_box() { .unwrap(); let node001 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -27,6 +29,10 @@ fn bevy_issue_16304__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -39,6 +45,10 @@ fn bevy_issue_16304__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -46,42 +56,237 @@ fn bevy_issue_16304__border_box() { ) .unwrap(); let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, &[node0]) + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node001, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node001, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node001, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -93,6 +298,7 @@ fn bevy_issue_16304__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -103,6 +309,7 @@ fn bevy_issue_16304__content_box() { let node001 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -116,6 +323,10 @@ fn bevy_issue_16304__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -129,6 +340,10 @@ fn bevy_issue_16304__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -140,6 +355,10 @@ fn bevy_issue_16304__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -149,34 +368,219 @@ fn bevy_issue_16304__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node001, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node001, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node001, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_21240.rs b/tests/generated/flex/bevy_issue_21240.rs index 9f160c193..a1ff34727 100644 --- a/tests/generated/flex/bevy_issue_21240.rs +++ b/tests/generated/flex/bevy_issue_21240.rs @@ -4,18 +4,40 @@ fn bevy_issue_21240__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: line(-1i16) }, ..Default::default() }) .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, ..Default::default() }) @@ -24,6 +46,10 @@ fn bevy_issue_21240__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32), length(40f32)], @@ -42,48 +68,281 @@ fn bevy_issue_21240__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 152f32, "height of node {:?}. Expected {}. Actual {}", node, 152f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 152f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node1, 56f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node1, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 56f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 104f32, "x of node {:?}. Expected {}. Actual {}", node2, 104f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node2, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 104f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 104f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 152f32, "x of node {:?}. Expected {}. Actual {}", node3, 152f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node3, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 152f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node4, 184f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node4, 8f32, location.x); - assert_eq!(location.y, 56f32, "y of node {:?}. Expected {}. Actual {}", node4, 56f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 56f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node5, 184f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node5, 8f32, location.x); - assert_eq!(location.y, 104f32, "y of node {:?}. Expected {}. Actual {}", node5, 104f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 104f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 104f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -93,20 +352,37 @@ fn bevy_issue_21240__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: line(-1i16) }, ..Default::default() }) @@ -114,6 +390,7 @@ fn bevy_issue_21240__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, ..Default::default() }) @@ -123,6 +400,10 @@ fn bevy_issue_21240__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32), length(40f32)], @@ -141,46 +422,279 @@ fn bevy_issue_21240__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 152f32, "height of node {:?}. Expected {}. Actual {}", node, 152f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 152f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node1, 56f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node1, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 56f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 104f32, "x of node {:?}. Expected {}. Actual {}", node2, 104f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node2, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 104f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 104f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 152f32, "x of node {:?}. Expected {}. Actual {}", node3, 152f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node3, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 152f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node4, 184f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node4, 8f32, location.x); - assert_eq!(location.y, 56f32, "y of node {:?}. Expected {}. Actual {}", node4, 56f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 56f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node5, 184f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node5, 8f32, location.x); - assert_eq!(location.y, 104f32, "y of node {:?}. Expected {}. Actual {}", node5, 104f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 104f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 104f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_7976_3_level.rs b/tests/generated/flex/bevy_issue_7976_3_level.rs index bdec628e9..76cf12798 100644 --- a/tests/generated/flex/bevy_issue_7976_3_level.rs +++ b/tests/generated/flex/bevy_issue_7976_3_level.rs @@ -6,6 +6,7 @@ fn bevy_issue_7976_3_level__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -22,6 +23,10 @@ fn bevy_issue_7976_3_level__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -46,6 +51,10 @@ fn bevy_issue_7976_3_level__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -60,24 +69,137 @@ fn bevy_issue_7976_3_level__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node00, 180f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +211,7 @@ fn bevy_issue_7976_3_level__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -106,6 +229,10 @@ fn bevy_issue_7976_3_level__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -131,6 +258,10 @@ fn bevy_issue_7976_3_level__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -145,22 +276,135 @@ fn bevy_issue_7976_3_level__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node00, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_7976_4_level.rs b/tests/generated/flex/bevy_issue_7976_4_level.rs index f9e8b3433..c4645d580 100644 --- a/tests/generated/flex/bevy_issue_7976_4_level.rs +++ b/tests/generated/flex/bevy_issue_7976_4_level.rs @@ -4,10 +4,19 @@ fn bevy_issue_7976_4_level__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node000 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -26,6 +35,10 @@ fn bevy_issue_7976_4_level__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -50,6 +63,10 @@ fn bevy_issue_7976_4_level__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -64,30 +81,182 @@ fn bevy_issue_7976_4_level__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node00, 180f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 170f32, "height of node {:?}. Expected {}. Actual {}", node000, 170f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node000, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node000, 5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 170f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 170f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,12 +266,20 @@ fn bevy_issue_7976_4_level__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -122,6 +299,10 @@ fn bevy_issue_7976_4_level__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -147,6 +328,10 @@ fn bevy_issue_7976_4_level__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -161,28 +346,180 @@ fn bevy_issue_7976_4_level__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node00, 190f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 190f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 190f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node000, 180f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node000, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node000, 5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_7976_reduced.rs b/tests/generated/flex/bevy_issue_7976_reduced.rs index 00857444b..f4381fa24 100644 --- a/tests/generated/flex/bevy_issue_7976_reduced.rs +++ b/tests/generated/flex/bevy_issue_7976_reduced.rs @@ -6,6 +6,7 @@ fn bevy_issue_7976_reduced__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, ..Default::default() }) @@ -13,6 +14,10 @@ fn bevy_issue_7976_reduced__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -24,18 +29,92 @@ fn bevy_issue_7976_reduced__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,6 +126,7 @@ fn bevy_issue_7976_reduced__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, ..Default::default() }) @@ -55,6 +135,10 @@ fn bevy_issue_7976_reduced__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -66,16 +150,90 @@ fn bevy_issue_7976_reduced__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_8017.rs b/tests/generated/flex/bevy_issue_8017.rs index 3e6967785..237d34aa3 100644 --- a/tests/generated/flex/bevy_issue_8017.rs +++ b/tests/generated/flex/bevy_issue_8017.rs @@ -6,6 +6,7 @@ fn bevy_issue_8017__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -15,6 +16,7 @@ fn bevy_issue_8017__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -26,6 +28,10 @@ fn bevy_issue_8017__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -38,6 +44,7 @@ fn bevy_issue_8017__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -47,6 +54,7 @@ fn bevy_issue_8017__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -58,6 +66,10 @@ fn bevy_issue_8017__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -73,6 +85,10 @@ fn bevy_issue_8017__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), @@ -93,48 +109,317 @@ fn bevy_issue_8017__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node0, 384f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node0, 188f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 384f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 384f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node00, 188f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node00, 188f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 188f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node01, 188f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node01, 188f32, size.height); - assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node01, 196f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 188f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 196f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node1, 384f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node1, 188f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1, 204f32, location.y); + if layout.size.width != 384f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 384f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 204f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 204f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node10, 188f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node10, 188f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 188f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node11, 188f32, size.width); - assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node11, 188f32, size.height); - assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node11, 196f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 188f32, layout.size.width); + } + if layout.size.height != 188f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 188f32, + layout.size.height + ); + } + if layout.location.x != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 196f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -146,6 +431,7 @@ fn bevy_issue_8017__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -156,6 +442,7 @@ fn bevy_issue_8017__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -168,6 +455,10 @@ fn bevy_issue_8017__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -181,6 +472,7 @@ fn bevy_issue_8017__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -191,6 +483,7 @@ fn bevy_issue_8017__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -203,6 +496,10 @@ fn bevy_issue_8017__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -219,6 +516,10 @@ fn bevy_issue_8017__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), @@ -239,46 +540,315 @@ fn bevy_issue_8017__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 416f32, "width of node {:?}. Expected {}. Actual {}", node, 416f32, size.width); - assert_eq!(size.height, 416f32, "height of node {:?}. Expected {}. Actual {}", node, 416f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 416f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 416f32, layout.size.width); + } + if layout.size.height != 416f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 416f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node0, 400f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node0, 196f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 196f32, "width of node {:?}. Expected {}. Actual {}", node00, 196f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node00, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 196f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 196f32, "width of node {:?}. Expected {}. Actual {}", node01, 196f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node01, 196f32, size.height); - assert_eq!(location.x, 204f32, "x of node {:?}. Expected {}. Actual {}", node01, 204f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 196f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 204f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 204f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node1, 400f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node1, 196f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); - assert_eq!(location.y, 212f32, "y of node {:?}. Expected {}. Actual {}", node1, 212f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 212f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 212f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 196f32, "width of node {:?}. Expected {}. Actual {}", node10, 196f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node10, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 196f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 196f32, "width of node {:?}. Expected {}. Actual {}", node11, 196f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node11, 196f32, size.height); - assert_eq!(location.x, 204f32, "x of node {:?}. Expected {}. Actual {}", node11, 204f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 196f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 196f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 204f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 204f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_8017_reduced.rs b/tests/generated/flex/bevy_issue_8017_reduced.rs index 0d52bcbff..41ba5a3e7 100644 --- a/tests/generated/flex/bevy_issue_8017_reduced.rs +++ b/tests/generated/flex/bevy_issue_8017_reduced.rs @@ -4,20 +4,38 @@ fn bevy_issue_8017_reduced__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.5f32) }, ..Default::default() }, &[node00], ) .unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.5f32) }, ..Default::default() }, @@ -28,6 +46,10 @@ fn bevy_issue_8017_reduced__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -42,36 +64,227 @@ fn bevy_issue_8017_reduced__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node0, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node00, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node1, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1, 204f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 204f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 204f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node10, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,12 +294,20 @@ fn bevy_issue_8017_reduced__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.5f32) }, ..Default::default() }, @@ -94,12 +315,20 @@ fn bevy_issue_8017_reduced__content_box() { ) .unwrap(); let node10 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.5f32) }, ..Default::default() }, @@ -111,6 +340,10 @@ fn bevy_issue_8017_reduced__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(8f32), height: length(8f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -125,34 +358,225 @@ fn bevy_issue_8017_reduced__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node0, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node00, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node1, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1, 204f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 204f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 204f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node10, 196f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 196f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 196f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_8082.rs b/tests/generated/flex/bevy_issue_8082.rs index 6ef23e9cc..b6976dcb1 100644 --- a/tests/generated/flex/bevy_issue_8082.rs +++ b/tests/generated/flex/bevy_issue_8082.rs @@ -6,6 +6,7 @@ fn bevy_issue_8082__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn bevy_issue_8082__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -36,6 +38,7 @@ fn bevy_issue_8082__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -51,6 +54,7 @@ fn bevy_issue_8082__border_box() { .unwrap(); let node03 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -68,6 +72,10 @@ fn bevy_issue_8082__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -80,6 +88,10 @@ fn bevy_issue_8082__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::FlexStart), @@ -96,42 +108,272 @@ fn bevy_issue_8082__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node00, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node01, 110f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node02, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node03, 110f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node03, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,6 +385,7 @@ fn bevy_issue_8082__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -159,6 +402,7 @@ fn bevy_issue_8082__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -175,6 +419,7 @@ fn bevy_issue_8082__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -191,6 +436,7 @@ fn bevy_issue_8082__content_box() { let node03 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -209,6 +455,10 @@ fn bevy_issue_8082__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -222,6 +472,10 @@ fn bevy_issue_8082__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::FlexStart), @@ -238,40 +492,270 @@ fn bevy_issue_8082__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node00, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node01, 110f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node02, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node03, 110f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node03, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_8082_percent.rs b/tests/generated/flex/bevy_issue_8082_percent.rs index 8ad6605fc..fc8657b5f 100644 --- a/tests/generated/flex/bevy_issue_8082_percent.rs +++ b/tests/generated/flex/bevy_issue_8082_percent.rs @@ -6,6 +6,7 @@ fn bevy_issue_8082_percent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn bevy_issue_8082_percent__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -24,6 +26,7 @@ fn bevy_issue_8082_percent__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -33,6 +36,7 @@ fn bevy_issue_8082_percent__border_box() { .unwrap(); let node03 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -44,6 +48,10 @@ fn bevy_issue_8082_percent__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -57,6 +65,10 @@ fn bevy_issue_8082_percent__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::FlexStart), @@ -73,42 +85,272 @@ fn bevy_issue_8082_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node02, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node03, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -120,6 +362,7 @@ fn bevy_issue_8082_percent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -130,6 +373,7 @@ fn bevy_issue_8082_percent__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -140,6 +384,7 @@ fn bevy_issue_8082_percent__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -150,6 +395,7 @@ fn bevy_issue_8082_percent__content_box() { let node03 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -162,6 +408,10 @@ fn bevy_issue_8082_percent__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -176,6 +426,10 @@ fn bevy_issue_8082_percent__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::FlexStart), @@ -192,40 +446,270 @@ fn bevy_issue_8082_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node02, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node03, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_9530.rs b/tests/generated/flex/bevy_issue_9530.rs index b2f0aedee..2b5ccebf0 100644 --- a/tests/generated/flex/bevy_issue_9530.rs +++ b/tests/generated/flex/bevy_issue_9530.rs @@ -7,6 +7,7 @@ fn bevy_issue_9530__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn bevy_issue_9530__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -23,9 +25,32 @@ fn bevy_issue_9530__border_box() { ..Default::default() }) .unwrap(); - let node11 = taffy . new_leaf_with_context (taffy :: style :: Style { align_items : Some (taffy :: style :: AlignItems :: Center) , align_content : Some (taffy :: style :: AlignContent :: Center) , justify_content : Some (taffy :: style :: JustifyContent :: Center) , flex_grow : 1f32 , margin : taffy :: geometry :: Rect { left : length (20f32) , right : length (20f32) , top : length (20f32) , bottom : length (20f32) , } , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node11_text = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; + let node11 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node11_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -37,6 +62,10 @@ fn bevy_issue_9530__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, margin: taffy::geometry::Rect { @@ -60,6 +89,10 @@ fn bevy_issue_9530__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { @@ -81,42 +114,266 @@ fn bevy_issue_9530__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 140f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node1, 300f32, size.width); - assert_eq!(size.height, 420f32, "height of node {:?}. Expected {}. Actual {}", node1, 420f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 420f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 420f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node10, 260f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node10, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 260f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 260f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 220f32, "width of node {:?}. Expected {}. Actual {}", node11, 220f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node11, 240f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node11, 90f32, location.y); + if layout.size.width != 220f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 220f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node12, 260f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node12, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node12, 20f32, location.x); - assert_eq!(location.y, 350f32, "y of node {:?}. Expected {}. Actual {}", node12, 350f32, location.y); + if layout.size.width != 260f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 260f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 350f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 350f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +386,7 @@ fn bevy_issue_9530__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(20f32), @@ -139,6 +397,7 @@ fn bevy_issue_9530__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -146,10 +405,34 @@ fn bevy_issue_9530__content_box() { ..Default::default() }) .unwrap(); - let node11 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , align_items : Some (taffy :: style :: AlignItems :: Center) , align_content : Some (taffy :: style :: AlignContent :: Center) , justify_content : Some (taffy :: style :: JustifyContent :: Center) , flex_grow : 1f32 , margin : taffy :: geometry :: Rect { left : length (20f32) , right : length (20f32) , top : length (20f32) , bottom : length (20f32) , } , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node11_text = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; + let node11 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node11_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -162,6 +445,10 @@ fn bevy_issue_9530__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, margin: taffy::geometry::Rect { @@ -186,6 +473,10 @@ fn bevy_issue_9530__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { @@ -207,40 +498,264 @@ fn bevy_issue_9530__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 340f32, "width of node {:?}. Expected {}. Actual {}", node1, 340f32, size.width); - assert_eq!(size.height, 380f32, "height of node {:?}. Expected {}. Actual {}", node1, 380f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node1, -20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 340f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 340f32, layout.size.width); + } + if layout.size.height != 380f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 380f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node10, 300f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node10, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node11, 260f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node11, 200f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node11, 90f32, location.y); + if layout.size.width != 260f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 260f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node12, 300f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node12, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node12, 20f32, location.x); - assert_eq!(location.y, 310f32, "y of node {:?}. Expected {}. Actual {}", node12, 310f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 310f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 310f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_9530_reduced.rs b/tests/generated/flex/bevy_issue_9530_reduced.rs index eaa24b427..d30e42630 100644 --- a/tests/generated/flex/bevy_issue_9530_reduced.rs +++ b/tests/generated/flex/bevy_issue_9530_reduced.rs @@ -6,7 +6,14 @@ fn bevy_issue_9530_reduced__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { flex_grow: 1f32, ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +21,10 @@ fn bevy_issue_9530_reduced__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -24,6 +35,10 @@ fn bevy_issue_9530_reduced__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, ..Default::default() }, @@ -34,24 +49,131 @@ fn bevy_issue_9530_reduced__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +186,10 @@ fn bevy_issue_9530_reduced__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -75,6 +201,10 @@ fn bevy_issue_9530_reduced__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -86,6 +216,10 @@ fn bevy_issue_9530_reduced__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, ..Default::default() }, @@ -96,22 +230,129 @@ fn bevy_issue_9530_reduced__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_9530_reduced2.rs b/tests/generated/flex/bevy_issue_9530_reduced2.rs index e314c8994..43e2df3de 100644 --- a/tests/generated/flex/bevy_issue_9530_reduced2.rs +++ b/tests/generated/flex/bevy_issue_9530_reduced2.rs @@ -6,7 +6,14 @@ fn bevy_issue_9530_reduced2__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { flex_grow: 1f32, ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + ..Default::default() + }, crate::TestNodeContext::ahem_text( "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal, @@ -17,6 +24,10 @@ fn bevy_issue_9530_reduced2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, margin: taffy::geometry::Rect { @@ -32,7 +43,14 @@ fn bevy_issue_9530_reduced2__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -40,24 +58,131 @@ fn bevy_issue_9530_reduced2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -70,6 +195,10 @@ fn bevy_issue_9530_reduced2__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -84,6 +213,10 @@ fn bevy_issue_9530_reduced2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, margin: taffy::geometry::Rect { @@ -102,6 +235,10 @@ fn bevy_issue_9530_reduced2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -111,22 +248,129 @@ fn bevy_issue_9530_reduced2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_9530_reduced3.rs b/tests/generated/flex/bevy_issue_9530_reduced3.rs index 6e0e78101..90a8c026f 100644 --- a/tests/generated/flex/bevy_issue_9530_reduced3.rs +++ b/tests/generated/flex/bevy_issue_9530_reduced3.rs @@ -7,6 +7,10 @@ fn bevy_issue_9530_reduced3__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(20f32), @@ -26,6 +30,10 @@ fn bevy_issue_9530_reduced3__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() }, @@ -36,18 +44,86 @@ fn bevy_issue_9530_reduced3__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +136,10 @@ fn bevy_issue_9530_reduced3__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(20f32), @@ -80,6 +160,10 @@ fn bevy_issue_9530_reduced3__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() }, @@ -90,16 +174,84 @@ fn bevy_issue_9530_reduced3__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/bevy_issue_9530_reduced4.rs b/tests/generated/flex/bevy_issue_9530_reduced4.rs index 6b2a3c402..8b8616faf 100644 --- a/tests/generated/flex/bevy_issue_9530_reduced4.rs +++ b/tests/generated/flex/bevy_issue_9530_reduced4.rs @@ -7,6 +7,10 @@ fn bevy_issue_9530_reduced4__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: length(20f32), right: length(20f32), @@ -25,6 +29,10 @@ fn bevy_issue_9530_reduced4__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() }, @@ -35,18 +43,86 @@ fn bevy_issue_9530_reduced4__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +135,10 @@ fn bevy_issue_9530_reduced4__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: length(20f32), right: length(20f32), @@ -78,6 +158,10 @@ fn bevy_issue_9530_reduced4__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() }, @@ -88,16 +172,84 @@ fn bevy_issue_9530_reduced4__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/blitz_issue_88.rs b/tests/generated/flex/blitz_issue_88.rs index 8bbbf3c8e..8eaeb86bb 100644 --- a/tests/generated/flex/blitz_issue_88.rs +++ b/tests/generated/flex/blitz_issue_88.rs @@ -8,6 +8,10 @@ fn blitz_issue_88__border_box() { .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -20,7 +24,15 @@ fn blitz_issue_88__border_box() { .unwrap(); let node00 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, flex_grow: 1f32, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_grow: 1f32, + ..Default::default() + }, &[node000], ) .unwrap(); @@ -29,6 +41,10 @@ fn blitz_issue_88__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), ..Default::default() }, @@ -39,6 +55,10 @@ fn blitz_issue_88__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() }, ..Default::default() }, @@ -49,30 +69,182 @@ fn blitz_issue_88__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 600f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +258,10 @@ fn blitz_issue_88__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -101,6 +277,10 @@ fn blitz_issue_88__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -113,6 +293,10 @@ fn blitz_issue_88__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), ..Default::default() }, @@ -124,6 +308,10 @@ fn blitz_issue_88__content_box() { taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() }, ..Default::default() }, @@ -134,28 +322,180 @@ fn blitz_issue_88__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 600f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_center_child.rs b/tests/generated/flex/border_center_child.rs index 643e54c83..00144471b 100644 --- a/tests/generated/flex/border_center_child.rs +++ b/tests/generated/flex/border_center_child.rs @@ -6,6 +6,7 @@ fn border_center_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn border_center_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -37,18 +42,86 @@ fn border_center_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +133,7 @@ fn border_center_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +145,10 @@ fn border_center_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -92,16 +170,84 @@ fn border_center_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 130f32, "height of node {:?}. Expected {}. Actual {}", node, 130f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 130f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node0, 55f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_container_match_child.rs b/tests/generated/flex/border_container_match_child.rs index b320aa6ec..9861e2ec2 100644 --- a/tests/generated/flex/border_container_match_child.rs +++ b/tests/generated/flex/border_container_match_child.rs @@ -6,6 +6,7 @@ fn border_container_match_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn border_container_match_child__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -32,18 +37,86 @@ fn border_container_match_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn border_container_match_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -67,6 +141,10 @@ fn border_container_match_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -82,16 +160,84 @@ fn border_container_match_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_flex_child.rs b/tests/generated/flex/border_flex_child.rs index 35fa229bd..1a81875c2 100644 --- a/tests/generated/flex/border_flex_child.rs +++ b/tests/generated/flex/border_flex_child.rs @@ -6,6 +6,7 @@ fn border_flex_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -14,6 +15,10 @@ fn border_flex_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn border_flex_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn border_flex_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -65,6 +139,10 @@ fn border_flex_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,90 @@ fn border_flex_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_no_child.rs b/tests/generated/flex/border_no_child.rs index 5d90ebed6..cc8e0585e 100644 --- a/tests/generated/flex/border_no_child.rs +++ b/tests/generated/flex/border_no_child.rs @@ -6,6 +6,7 @@ fn border_no_child__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -19,12 +20,47 @@ fn border_no_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -36,6 +72,7 @@ fn border_no_child__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -49,10 +86,45 @@ fn border_no_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_no_size.rs b/tests/generated/flex/border_no_size.rs index 08ec572ae..24a2b6cb1 100644 --- a/tests/generated/flex/border_no_size.rs +++ b/tests/generated/flex/border_no_size.rs @@ -7,6 +7,7 @@ fn border_no_size__border_box() { let node = taffy .new_leaf(taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -20,12 +21,47 @@ fn border_no_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -38,6 +74,7 @@ fn border_no_size__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -51,10 +88,45 @@ fn border_no_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/border_stretch_child.rs b/tests/generated/flex/border_stretch_child.rs index aed6d96be..3e1fa8db8 100644 --- a/tests/generated/flex/border_stretch_child.rs +++ b/tests/generated/flex/border_stretch_child.rs @@ -6,6 +6,7 @@ fn border_stretch_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -13,6 +14,10 @@ fn border_stretch_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn border_stretch_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn border_stretch_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -63,6 +137,10 @@ fn border_stretch_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,90 @@ fn border_stretch_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/child_min_max_width_flexing.rs b/tests/generated/flex/child_min_max_width_flexing.rs index 3899fe076..6e3fa2632 100644 --- a/tests/generated/flex/child_min_max_width_flexing.rs +++ b/tests/generated/flex/child_min_max_width_flexing.rs @@ -6,6 +6,7 @@ fn child_min_max_width_flexing__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(0f32), @@ -15,6 +16,7 @@ fn child_min_max_width_flexing__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), @@ -25,6 +27,10 @@ fn child_min_max_width_flexing__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -39,24 +45,125 @@ fn child_min_max_width_flexing__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn child_min_max_width_flexing__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(0f32), @@ -78,6 +186,7 @@ fn child_min_max_width_flexing__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), @@ -89,6 +198,10 @@ fn child_min_max_width_flexing__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), @@ -103,22 +216,123 @@ fn child_min_max_width_flexing__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/child_with_padding_align_end.rs b/tests/generated/flex/child_with_padding_align_end.rs index a9918d889..05c7a629a 100644 --- a/tests/generated/flex/child_with_padding_align_end.rs +++ b/tests/generated/flex/child_with_padding_align_end.rs @@ -6,6 +6,7 @@ fn child_with_padding_align_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -23,6 +24,10 @@ fn child_with_padding_align_end__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -38,18 +43,92 @@ fn child_with_padding_align_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +140,7 @@ fn child_with_padding_align_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -79,6 +159,10 @@ fn child_with_padding_align_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -94,16 +178,90 @@ fn child_with_padding_align_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/container_with_unsized_child.rs b/tests/generated/flex/container_with_unsized_child.rs index 0a9a04307..ae267f59e 100644 --- a/tests/generated/flex/container_with_unsized_child.rs +++ b/tests/generated/flex/container_with_unsized_child.rs @@ -4,10 +4,19 @@ fn container_with_unsized_child__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -21,18 +30,92 @@ fn container_with_unsized_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,12 +125,20 @@ fn container_with_unsized_child__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -61,16 +152,90 @@ fn container_with_unsized_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/content_size.rs b/tests/generated/flex/content_size.rs index f8c56252d..cd4b09161 100644 --- a/tests/generated/flex/content_size.rs +++ b/tests/generated/flex/content_size.rs @@ -8,6 +8,10 @@ fn content_size__border_box() { .new_leaf_with_context( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -22,6 +26,10 @@ fn content_size__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(30f32) }, ..Default::default() }, @@ -51,42 +59,131 @@ fn content_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0, 85f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node00, 85f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node00, -10f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +197,10 @@ fn content_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -115,6 +216,10 @@ fn content_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(30f32) }, ..Default::default() }, @@ -145,40 +250,129 @@ fn content_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0, 85f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node00, 85f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node00, -10f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/content_size_with_border.rs b/tests/generated/flex/content_size_with_border.rs new file mode 100644 index 000000000..ec2a2df12 --- /dev/null +++ b/tests/generated/flex/content_size_with_border.rs @@ -0,0 +1,2334 @@ +#[test] +#[allow(non_snake_case)] +fn content_size_with_border__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node1 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node2 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node3 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node4 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node5 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node6 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node7 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node8 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node9 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node10 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node11 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node12 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node13 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node14 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node15 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node16 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node17 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node18 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node19 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(50f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, node16, node17, node18, node19, + ], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 156f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 156f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node1).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node2).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 21f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node3).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node4).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 41f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node5).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 51f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node6).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 61f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node7).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 71f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node8).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 81f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 81f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node9).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 91f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node10).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 101f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node11).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 111f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node12).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 121f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 121f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node13).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 131f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 131f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node14).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 141f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 141f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node15).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 151f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 151f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node16).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 161f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.y), 161f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node17).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 171f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.y), 171f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node18).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 181f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.y), 181f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node19).unwrap(); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 191f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.y), 191f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 125f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_width()), + 125f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn content_size_with_border__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node1 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node2 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node3 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node4 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node5 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node6 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node7 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node8 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node9 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node10 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node11 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node12 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node13 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node14 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node15 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node16 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node17 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node18 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node19 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("XXXXXXXXXXXXXXXXXXXX", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(50f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, node16, node17, node18, node19, + ], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 56f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 150f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node1).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node2).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 21f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node3).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node4).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 41f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node5).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 51f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node6).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 61f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node7).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 71f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node8).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 81f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 81f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node9).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 91f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node10).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 101f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node11).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 111f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node12).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 121f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 121f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node13).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 131f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 131f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node14).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 141f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 141f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node15).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 151f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 151f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node16).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 161f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.y), 161f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node17).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 171f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.y), 171f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node18).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 181f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.y), 181f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node19).unwrap(); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.x), 7f32, layout.location.x); + } + if layout.location.y != 191f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.y), 191f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 115f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_width()), + 115f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/display_none.rs b/tests/generated/flex/display_none.rs index aab742dba..c5d5d130d 100644 --- a/tests/generated/flex/display_none.rs +++ b/tests/generated/flex/display_none.rs @@ -4,13 +4,28 @@ fn display_none__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }) + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -24,24 +39,131 @@ fn display_none__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +175,7 @@ fn display_none__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -61,6 +184,7 @@ fn display_none__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -69,6 +193,10 @@ fn display_none__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,22 +210,129 @@ fn display_none__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_absolute_child.rs b/tests/generated/flex/display_none_absolute_child.rs index 691ca6e39..0ce771caa 100644 --- a/tests/generated/flex/display_none_absolute_child.rs +++ b/tests/generated/flex/display_none_absolute_child.rs @@ -4,11 +4,18 @@ fn display_none_absolute_child__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -20,6 +27,10 @@ fn display_none_absolute_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,24 +44,131 @@ fn display_none_absolute_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +180,7 @@ fn display_none_absolute_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -71,6 +190,7 @@ fn display_none_absolute_child__content_box() { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -83,6 +203,10 @@ fn display_none_absolute_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -96,22 +220,129 @@ fn display_none_absolute_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_fixed_size.rs b/tests/generated/flex/display_none_fixed_size.rs index 5cdfe3375..d4a384426 100644 --- a/tests/generated/flex/display_none_fixed_size.rs +++ b/tests/generated/flex/display_none_fixed_size.rs @@ -4,10 +4,17 @@ fn display_none_fixed_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +25,10 @@ fn display_none_fixed_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,24 +42,131 @@ fn display_none_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +178,7 @@ fn display_none_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -68,6 +187,7 @@ fn display_none_fixed_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -79,6 +199,10 @@ fn display_none_fixed_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -92,22 +216,129 @@ fn display_none_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_only_node.rs b/tests/generated/flex/display_none_only_node.rs index 71a7bb570..6a0ba46d6 100644 --- a/tests/generated/flex/display_none_only_node.rs +++ b/tests/generated/flex/display_none_only_node.rs @@ -7,6 +7,7 @@ fn display_none_only_node__border_box() { let node = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -18,12 +19,47 @@ fn display_none_only_node__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -36,6 +72,7 @@ fn display_none_only_node__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -47,10 +84,45 @@ fn display_none_only_node__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_with_child.rs b/tests/generated/flex/display_none_with_child.rs index 903dfa829..65f2a63a9 100644 --- a/tests/generated/flex/display_none_with_child.rs +++ b/tests/generated/flex/display_none_with_child.rs @@ -6,6 +6,7 @@ fn display_none_with_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -14,6 +15,7 @@ fn display_none_with_child__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -26,6 +28,10 @@ fn display_none_with_child__border_box() { taffy::style::Style { display: taffy::style::Display::None, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -36,6 +42,7 @@ fn display_none_with_child__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -45,6 +52,10 @@ fn display_none_with_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -58,36 +69,215 @@ fn display_none_with_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +289,7 @@ fn display_none_with_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -108,6 +299,7 @@ fn display_none_with_child__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -121,6 +313,10 @@ fn display_none_with_child__content_box() { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -132,6 +328,7 @@ fn display_none_with_child__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -142,6 +339,10 @@ fn display_none_with_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -155,34 +356,213 @@ fn display_none_with_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_with_margin.rs b/tests/generated/flex/display_none_with_margin.rs index 58a01a17a..10a673104 100644 --- a/tests/generated/flex/display_none_with_margin.rs +++ b/tests/generated/flex/display_none_with_margin.rs @@ -7,6 +7,7 @@ fn display_none_with_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -20,10 +21,20 @@ fn display_none_with_margin__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,24 +48,131 @@ fn display_none_with_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +185,7 @@ fn display_none_with_margin__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -83,6 +202,7 @@ fn display_none_with_margin__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -91,6 +211,10 @@ fn display_none_with_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -104,22 +228,129 @@ fn display_none_with_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_with_position.rs b/tests/generated/flex/display_none_with_position.rs index 708aefe75..5cb6b30e5 100644 --- a/tests/generated/flex/display_none_with_position.rs +++ b/tests/generated/flex/display_none_with_position.rs @@ -4,10 +4,17 @@ fn display_none_with_position__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() }, ..Default::default() @@ -16,6 +23,10 @@ fn display_none_with_position__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,24 +40,131 @@ fn display_none_with_position__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +176,7 @@ fn display_none_with_position__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -66,6 +185,7 @@ fn display_none_with_position__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() }, ..Default::default() @@ -75,6 +195,10 @@ fn display_none_with_position__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,22 +212,129 @@ fn display_none_with_position__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/display_none_with_position_absolute.rs b/tests/generated/flex/display_none_with_position_absolute.rs index 76b9789d7..34ab46924 100644 --- a/tests/generated/flex/display_none_with_position_absolute.rs +++ b/tests/generated/flex/display_none_with_position_absolute.rs @@ -8,6 +8,7 @@ fn display_none_with_position_absolute__border_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -18,6 +19,10 @@ fn display_none_with_position_absolute__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn display_none_with_position_absolute__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn display_none_with_position_absolute__content_box() { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -67,6 +141,10 @@ fn display_none_with_position_absolute__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn display_none_with_position_absolute__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs b/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs index c52f79796..3494987d3 100644 --- a/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs +++ b/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs @@ -6,6 +6,7 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -18,6 +19,10 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ taffy::style::Style { position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }, @@ -45,42 +50,137 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 50f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 50f32, - layout.scroll_height() - ); + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -92,6 +192,7 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -105,6 +206,10 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }, @@ -133,40 +238,135 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 50f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 50f32, - layout.scroll_height() - ); + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_absolute_overflow_clip.rs b/tests/generated/flex/flex_absolute_overflow_clip.rs new file mode 100644 index 000000000..8c17fd0e5 --- /dev/null +++ b/tests/generated/flex/flex_absolute_overflow_clip.rs @@ -0,0 +1,293 @@ +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_absolute_overflow_hidden.rs b/tests/generated/flex/flex_absolute_overflow_hidden.rs new file mode 100644 index 000000000..162cb8b98 --- /dev/null +++ b/tests/generated/flex/flex_absolute_overflow_hidden.rs @@ -0,0 +1,301 @@ +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_absolute_overflow_scroll.rs b/tests/generated/flex/flex_absolute_overflow_scroll.rs new file mode 100644 index 000000000..be0f56635 --- /dev/null +++ b/tests/generated/flex/flex_absolute_overflow_scroll.rs @@ -0,0 +1,301 @@ +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 66f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 66f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 43f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 43f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 52f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 52f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_absolute_overflow_visible.rs b/tests/generated/flex/flex_absolute_overflow_visible.rs new file mode 100644 index 000000000..6400ec285 --- /dev/null +++ b/tests/generated/flex/flex_absolute_overflow_visible.rs @@ -0,0 +1,299 @@ +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_absolute_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs b/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs index d3b3c0563..781100fe8 100644 --- a/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs +++ b/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs @@ -6,6 +6,7 @@ fn flex_basis_and_main_dimen_set_when_flexing__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn flex_basis_and_main_dimen_set_when_flexing__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { @@ -29,6 +31,10 @@ fn flex_basis_and_main_dimen_set_when_flexing__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -39,24 +45,125 @@ fn flex_basis_and_main_dimen_set_when_flexing__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +175,7 @@ fn flex_basis_and_main_dimen_set_when_flexing__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { @@ -80,6 +188,7 @@ fn flex_basis_and_main_dimen_set_when_flexing__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { @@ -93,6 +202,10 @@ fn flex_basis_and_main_dimen_set_when_flexing__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -103,22 +216,123 @@ fn flex_basis_and_main_dimen_set_when_flexing__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_flex_grow_column.rs b/tests/generated/flex/flex_basis_flex_grow_column.rs index 58b55d1e4..ed87fb5a6 100644 --- a/tests/generated/flex/flex_basis_flex_grow_column.rs +++ b/tests/generated/flex/flex_basis_flex_grow_column.rs @@ -6,16 +6,27 @@ fn flex_basis_flex_grow_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,24 +40,125 @@ fn flex_basis_flex_grow_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +170,7 @@ fn flex_basis_flex_grow_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() @@ -66,6 +179,7 @@ fn flex_basis_flex_grow_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -75,6 +189,10 @@ fn flex_basis_flex_grow_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,22 +206,123 @@ fn flex_basis_flex_grow_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_flex_grow_row.rs b/tests/generated/flex/flex_basis_flex_grow_row.rs index ada880e52..dfc8c804e 100644 --- a/tests/generated/flex/flex_basis_flex_grow_row.rs +++ b/tests/generated/flex/flex_basis_flex_grow_row.rs @@ -6,15 +6,26 @@ fn flex_basis_flex_grow_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,24 +39,137 @@ fn flex_basis_flex_grow_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node0, 75f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node1, 25f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +181,7 @@ fn flex_basis_flex_grow_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() @@ -65,6 +190,7 @@ fn flex_basis_flex_grow_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -73,6 +199,10 @@ fn flex_basis_flex_grow_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,22 +216,135 @@ fn flex_basis_flex_grow_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node0, 75f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node1, 25f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_flex_shrink_column.rs b/tests/generated/flex/flex_basis_flex_shrink_column.rs index fc0b36347..3974a78e3 100644 --- a/tests/generated/flex/flex_basis_flex_shrink_column.rs +++ b/tests/generated/flex/flex_basis_flex_shrink_column.rs @@ -6,17 +6,26 @@ fn flex_basis_flex_shrink_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_basis: taffy::style::Dimension::from_length(50f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -30,24 +39,125 @@ fn flex_basis_flex_shrink_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +169,7 @@ fn flex_basis_flex_shrink_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() }) @@ -66,6 +177,7 @@ fn flex_basis_flex_shrink_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) @@ -75,6 +187,10 @@ fn flex_basis_flex_shrink_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,22 +204,123 @@ fn flex_basis_flex_shrink_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_flex_shrink_row.rs b/tests/generated/flex/flex_basis_flex_shrink_row.rs index 052ddd6e8..1becc5e39 100644 --- a/tests/generated/flex/flex_basis_flex_shrink_row.rs +++ b/tests/generated/flex/flex_basis_flex_shrink_row.rs @@ -6,16 +6,25 @@ fn flex_basis_flex_shrink_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_basis: taffy::style::Dimension::from_length(50f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,24 +38,137 @@ fn flex_basis_flex_shrink_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node1, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +180,7 @@ fn flex_basis_flex_shrink_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() }) @@ -65,6 +188,7 @@ fn flex_basis_flex_shrink_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }) @@ -73,6 +197,10 @@ fn flex_basis_flex_shrink_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,22 +214,135 @@ fn flex_basis_flex_shrink_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node1, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_larger_than_content_column.rs b/tests/generated/flex/flex_basis_larger_than_content_column.rs index aef8efd85..4601ad204 100644 --- a/tests/generated/flex/flex_basis_larger_than_content_column.rs +++ b/tests/generated/flex/flex_basis_larger_than_content_column.rs @@ -6,6 +6,7 @@ fn flex_basis_larger_than_content_column__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn flex_basis_larger_than_content_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -27,6 +32,10 @@ fn flex_basis_larger_than_content_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -37,24 +46,131 @@ fn flex_basis_larger_than_content_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +182,7 @@ fn flex_basis_larger_than_content_column__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(10f32), @@ -78,6 +195,10 @@ fn flex_basis_larger_than_content_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -89,6 +210,10 @@ fn flex_basis_larger_than_content_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -99,22 +224,129 @@ fn flex_basis_larger_than_content_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_larger_than_content_row.rs b/tests/generated/flex/flex_basis_larger_than_content_row.rs index 17345b5a6..143da75a9 100644 --- a/tests/generated/flex/flex_basis_larger_than_content_row.rs +++ b/tests/generated/flex/flex_basis_larger_than_content_row.rs @@ -6,6 +6,7 @@ fn flex_basis_larger_than_content_row__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_larger_than_content_row__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -26,6 +31,10 @@ fn flex_basis_larger_than_content_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -36,24 +45,137 @@ fn flex_basis_larger_than_content_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +187,7 @@ fn flex_basis_larger_than_content_row__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(100f32), @@ -77,6 +200,10 @@ fn flex_basis_larger_than_content_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -87,6 +214,10 @@ fn flex_basis_larger_than_content_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -97,22 +228,135 @@ fn flex_basis_larger_than_content_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_overrides_main_size.rs b/tests/generated/flex/flex_basis_overrides_main_size.rs index 4b77a7fcb..16d6492bc 100644 --- a/tests/generated/flex/flex_basis_overrides_main_size.rs +++ b/tests/generated/flex/flex_basis_overrides_main_size.rs @@ -6,6 +6,7 @@ fn flex_basis_overrides_main_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, @@ -14,6 +15,7 @@ fn flex_basis_overrides_main_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -21,6 +23,7 @@ fn flex_basis_overrides_main_size__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -29,6 +32,10 @@ fn flex_basis_overrides_main_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -42,30 +49,182 @@ fn flex_basis_overrides_main_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +236,7 @@ fn flex_basis_overrides_main_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, @@ -86,6 +246,7 @@ fn flex_basis_overrides_main_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -94,6 +255,7 @@ fn flex_basis_overrides_main_size__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -103,6 +265,10 @@ fn flex_basis_overrides_main_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -116,28 +282,180 @@ fn flex_basis_overrides_main_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs index 4994271a3..4bf601159 100644 --- a/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -6,6 +6,7 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(60f32), ..Default::default() @@ -26,6 +31,7 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -47,6 +57,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__border_bo println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(60f32), ..Default::default() @@ -120,6 +330,7 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -143,6 +358,10 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size__content_b println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_than_content_column.rs b/tests/generated/flex/flex_basis_smaller_than_content_column.rs index 9e78f965f..427f07af7 100644 --- a/tests/generated/flex/flex_basis_smaller_than_content_column.rs +++ b/tests/generated/flex/flex_basis_smaller_than_content_column.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_than_content_column__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_than_content_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -27,6 +32,10 @@ fn flex_basis_smaller_than_content_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -37,24 +46,137 @@ fn flex_basis_smaller_than_content_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +188,7 @@ fn flex_basis_smaller_than_content_column__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -78,6 +201,10 @@ fn flex_basis_smaller_than_content_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -89,6 +216,10 @@ fn flex_basis_smaller_than_content_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -99,22 +230,135 @@ fn flex_basis_smaller_than_content_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_than_content_row.rs b/tests/generated/flex/flex_basis_smaller_than_content_row.rs index f6f208a05..cd0c6ee1c 100644 --- a/tests/generated/flex/flex_basis_smaller_than_content_row.rs +++ b/tests/generated/flex/flex_basis_smaller_than_content_row.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_than_content_row__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_than_content_row__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -26,6 +31,10 @@ fn flex_basis_smaller_than_content_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -36,24 +45,137 @@ fn flex_basis_smaller_than_content_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +187,7 @@ fn flex_basis_smaller_than_content_row__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -77,6 +200,10 @@ fn flex_basis_smaller_than_content_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -87,6 +214,10 @@ fn flex_basis_smaller_than_content_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -97,22 +228,135 @@ fn flex_basis_smaller_than_content_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs b/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs index f8f667bcc..6706d6772 100644 --- a/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs +++ b/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_than_main_dimen_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,10 @@ fn flex_basis_smaller_than_main_dimen_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -28,18 +33,86 @@ fn flex_basis_smaller_than_main_dimen_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn flex_basis_smaller_than_main_dimen_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -64,6 +138,10 @@ fn flex_basis_smaller_than_main_dimen_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -74,16 +152,84 @@ fn flex_basis_smaller_than_main_dimen_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs b/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs index 22c474d71..199bc1f9d 100644 --- a/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs +++ b/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_than_main_dimen_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_than_main_dimen_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -27,18 +32,86 @@ fn flex_basis_smaller_than_main_dimen_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +123,7 @@ fn flex_basis_smaller_than_main_dimen_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(10f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -62,6 +136,10 @@ fn flex_basis_smaller_than_main_dimen_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -72,16 +150,84 @@ fn flex_basis_smaller_than_main_dimen_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs index 2355f6d1a..6afe294ef 100644 --- a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -26,6 +31,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -47,6 +57,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -120,6 +330,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -143,6 +358,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs index 36c0d7f0e..b292f2d00 100644 --- a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -26,6 +31,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -47,6 +57,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 80f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -120,6 +330,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -143,6 +358,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 80f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs index e80850837..1fa856315 100644 --- a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__border_box( let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__border_box( .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -26,6 +31,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__border_box( .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__border_box( .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -44,41 +54,243 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__border_box( &[node10], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +302,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -102,6 +315,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -112,6 +329,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -124,6 +342,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -133,7 +355,14 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -141,34 +370,225 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size__content_box println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs index ecf7402a6..c90a27739 100644 --- a/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -6,6 +6,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -26,6 +31,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -47,6 +57,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__border_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -120,6 +330,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -143,6 +358,10 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size__content_box() println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_unconstraint_column.rs b/tests/generated/flex/flex_basis_unconstraint_column.rs index 2a9f1f7db..ac81ffed4 100644 --- a/tests/generated/flex/flex_basis_unconstraint_column.rs +++ b/tests/generated/flex/flex_basis_unconstraint_column.rs @@ -6,6 +6,7 @@ fn flex_basis_unconstraint_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -13,7 +14,14 @@ fn flex_basis_unconstraint_column__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -21,18 +29,86 @@ fn flex_basis_unconstraint_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -44,6 +120,7 @@ fn flex_basis_unconstraint_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -54,6 +131,10 @@ fn flex_basis_unconstraint_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -63,16 +144,84 @@ fn flex_basis_unconstraint_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_unconstraint_row.rs b/tests/generated/flex/flex_basis_unconstraint_row.rs index 122ff042b..7ac844d40 100644 --- a/tests/generated/flex/flex_basis_unconstraint_row.rs +++ b/tests/generated/flex/flex_basis_unconstraint_row.rs @@ -6,28 +6,114 @@ fn flex_basis_unconstraint_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +125,7 @@ fn flex_basis_unconstraint_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -46,7 +133,14 @@ fn flex_basis_unconstraint_row__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +148,90 @@ fn flex_basis_unconstraint_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_basis_zero_undefined_main_size.rs b/tests/generated/flex/flex_basis_zero_undefined_main_size.rs index 2468fd855..450be5721 100644 --- a/tests/generated/flex/flex_basis_zero_undefined_main_size.rs +++ b/tests/generated/flex/flex_basis_zero_undefined_main_size.rs @@ -6,6 +6,7 @@ fn flex_basis_zero_undefined_main_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,35 +18,157 @@ fn flex_basis_zero_undefined_main_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() }, &[node00], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +180,7 @@ fn flex_basis_zero_undefined_main_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(50f32), @@ -69,6 +193,10 @@ fn flex_basis_zero_undefined_main_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() }, @@ -77,7 +205,14 @@ fn flex_basis_zero_undefined_main_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -85,22 +220,129 @@ fn flex_basis_zero_undefined_main_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_column_relative_all_sides.rs b/tests/generated/flex/flex_column_relative_all_sides.rs index 115ae42ac..57c50d332 100644 --- a/tests/generated/flex/flex_column_relative_all_sides.rs +++ b/tests/generated/flex/flex_column_relative_all_sides.rs @@ -6,6 +6,7 @@ fn flex_column_relative_all_sides__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -20,6 +21,10 @@ fn flex_column_relative_all_sides__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn flex_column_relative_all_sides__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn flex_column_relative_all_sides__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -71,6 +145,10 @@ fn flex_column_relative_all_sides__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,84 @@ fn flex_column_relative_all_sides__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_column.rs b/tests/generated/flex/flex_direction_column.rs index 57b34df73..7664468d9 100644 --- a/tests/generated/flex/flex_direction_column.rs +++ b/tests/generated/flex/flex_direction_column.rs @@ -6,18 +6,21 @@ fn flex_direction_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn flex_direction_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,164 @@ fn flex_direction_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +215,7 @@ fn flex_direction_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -81,6 +223,7 @@ fn flex_direction_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +231,7 @@ fn flex_direction_column__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -97,6 +241,10 @@ fn flex_direction_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,28 +258,162 @@ fn flex_direction_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_column_no_height.rs b/tests/generated/flex/flex_direction_column_no_height.rs index e2bb6e282..8111c8bb0 100644 --- a/tests/generated/flex/flex_direction_column_no_height.rs +++ b/tests/generated/flex/flex_direction_column_no_height.rs @@ -6,18 +6,21 @@ fn flex_direction_column_no_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn flex_direction_column_no_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -36,30 +43,164 @@ fn flex_direction_column_no_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +212,7 @@ fn flex_direction_column_no_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -78,6 +220,7 @@ fn flex_direction_column_no_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -85,6 +228,7 @@ fn flex_direction_column_no_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -94,6 +238,10 @@ fn flex_direction_column_no_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -104,28 +252,162 @@ fn flex_direction_column_no_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_column_reverse.rs b/tests/generated/flex/flex_direction_column_reverse.rs index ea5a89f47..e4814e96b 100644 --- a/tests/generated/flex/flex_direction_column_reverse.rs +++ b/tests/generated/flex/flex_direction_column_reverse.rs @@ -6,18 +6,21 @@ fn flex_direction_column_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn flex_direction_column_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,164 @@ fn flex_direction_column_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node2, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +215,7 @@ fn flex_direction_column_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -81,6 +223,7 @@ fn flex_direction_column_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +231,7 @@ fn flex_direction_column_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -97,6 +241,10 @@ fn flex_direction_column_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,28 +258,162 @@ fn flex_direction_column_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node2, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_column_reverse_no_height.rs b/tests/generated/flex/flex_direction_column_reverse_no_height.rs index e98bc75bc..d0574e6eb 100644 --- a/tests/generated/flex/flex_direction_column_reverse_no_height.rs +++ b/tests/generated/flex/flex_direction_column_reverse_no_height.rs @@ -6,18 +6,21 @@ fn flex_direction_column_reverse_no_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn flex_direction_column_reverse_no_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -36,30 +43,164 @@ fn flex_direction_column_reverse_no_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +212,7 @@ fn flex_direction_column_reverse_no_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -78,6 +220,7 @@ fn flex_direction_column_reverse_no_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -85,6 +228,7 @@ fn flex_direction_column_reverse_no_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -94,6 +238,10 @@ fn flex_direction_column_reverse_no_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -104,28 +252,162 @@ fn flex_direction_column_reverse_no_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_row.rs b/tests/generated/flex/flex_direction_row.rs index 941b10e20..e9ec8cc95 100644 --- a/tests/generated/flex/flex_direction_row.rs +++ b/tests/generated/flex/flex_direction_row.rs @@ -6,18 +6,21 @@ fn flex_direction_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn flex_direction_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -38,30 +45,182 @@ fn flex_direction_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +232,7 @@ fn flex_direction_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -80,6 +240,7 @@ fn flex_direction_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -87,6 +248,7 @@ fn flex_direction_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -95,6 +257,10 @@ fn flex_direction_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -108,28 +274,180 @@ fn flex_direction_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_row_no_width.rs b/tests/generated/flex/flex_direction_row_no_width.rs index 38e58b590..ca79a13b4 100644 --- a/tests/generated/flex/flex_direction_row_no_width.rs +++ b/tests/generated/flex/flex_direction_row_no_width.rs @@ -6,18 +6,21 @@ fn flex_direction_row_no_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn flex_direction_row_no_width__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -35,30 +42,182 @@ fn flex_direction_row_no_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -70,6 +229,7 @@ fn flex_direction_row_no_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -77,6 +237,7 @@ fn flex_direction_row_no_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -84,6 +245,7 @@ fn flex_direction_row_no_width__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -92,6 +254,10 @@ fn flex_direction_row_no_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -102,28 +268,180 @@ fn flex_direction_row_no_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_direction_row_reverse.rs b/tests/generated/flex/flex_direction_row_reverse.rs index 99b0a2ac7..a4826c572 100644 --- a/tests/generated/flex/flex_direction_row_reverse.rs +++ b/tests/generated/flex/flex_direction_row_reverse.rs @@ -6,18 +6,21 @@ fn flex_direction_row_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -26,6 +29,10 @@ fn flex_direction_row_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::RowReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn flex_direction_row_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn flex_direction_row_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn flex_direction_row_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn flex_direction_row_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn flex_direction_row_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::RowReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn flex_direction_row_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_0_min_size.rs b/tests/generated/flex/flex_grow_0_min_size.rs index 704c2e1e1..acbfc8745 100644 --- a/tests/generated/flex/flex_grow_0_min_size.rs +++ b/tests/generated/flex/flex_grow_0_min_size.rs @@ -7,6 +7,10 @@ fn flex_grow_0_min_size__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -18,6 +22,10 @@ fn flex_grow_0_min_size__border_box() { let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -29,6 +37,10 @@ fn flex_grow_0_min_size__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -40,6 +52,10 @@ fn flex_grow_0_min_size__border_box() { let node3 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -52,6 +68,10 @@ fn flex_grow_0_min_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(100f32), @@ -71,36 +91,203 @@ fn flex_grow_0_min_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 98f32, "height of node {:?}. Expected {}. Actual {}", node0, 98f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 98f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 98f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 98f32, "height of node {:?}. Expected {}. Actual {}", node1, 98f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node1, 1f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 98f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 98f32, layout.size.height); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 98f32, "height of node {:?}. Expected {}. Actual {}", node2, 98f32, size.height); - assert_eq!(location.x, 61f32, "x of node {:?}. Expected {}. Actual {}", node2, 61f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node2, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 98f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 98f32, layout.size.height); + } + if layout.location.x != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 61f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 98f32, "height of node {:?}. Expected {}. Actual {}", node3, 98f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node3, 111f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node3, 1f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 98f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 98f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +300,10 @@ fn flex_grow_0_min_size__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -125,6 +316,10 @@ fn flex_grow_0_min_size__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -137,6 +332,10 @@ fn flex_grow_0_min_size__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -149,6 +348,10 @@ fn flex_grow_0_min_size__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -162,6 +365,10 @@ fn flex_grow_0_min_size__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(100f32), @@ -181,34 +388,225 @@ fn flex_grow_0_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 402f32, "width of node {:?}. Expected {}. Actual {}", node, 402f32, size.width); - assert_eq!(size.height, 102f32, "height of node {:?}. Expected {}. Actual {}", node, 102f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 402f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 402f32, layout.size.width); + } + if layout.size.height != 102f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 102f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node1, 1f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 61f32, "x of node {:?}. Expected {}. Actual {}", node2, 61f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node2, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 61f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node3, 111f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node3, 1f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_child.rs b/tests/generated/flex/flex_grow_child.rs index dcbd9050f..15ba892c6 100644 --- a/tests/generated/flex/flex_grow_child.rs +++ b/tests/generated/flex/flex_grow_child.rs @@ -6,29 +6,115 @@ fn flex_grow_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -40,6 +126,7 @@ fn flex_grow_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -48,7 +135,14 @@ fn flex_grow_child__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -56,16 +150,90 @@ fn flex_grow_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_flex_basis_percent_min_max.rs b/tests/generated/flex/flex_grow_flex_basis_percent_min_max.rs index e0479e478..cc9ff3f4e 100644 --- a/tests/generated/flex/flex_grow_flex_basis_percent_min_max.rs +++ b/tests/generated/flex/flex_grow_flex_basis_percent_min_max.rs @@ -6,6 +6,7 @@ fn flex_grow_flex_basis_percent_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(0f32), @@ -16,6 +17,7 @@ fn flex_grow_flex_basis_percent_min_max__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), @@ -30,6 +32,10 @@ fn flex_grow_flex_basis_percent_min_max__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), height: auto() }, ..Default::default() }, @@ -40,24 +46,125 @@ fn flex_grow_flex_basis_percent_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -69,6 +176,7 @@ fn flex_grow_flex_basis_percent_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(0f32), @@ -80,6 +188,7 @@ fn flex_grow_flex_basis_percent_min_max__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), @@ -95,6 +204,10 @@ fn flex_grow_flex_basis_percent_min_max__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(120f32), height: auto() }, ..Default::default() }, @@ -105,22 +218,123 @@ fn flex_grow_flex_basis_percent_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_height_maximized.rs b/tests/generated/flex/flex_grow_height_maximized.rs index d95cfadcf..088241326 100644 --- a/tests/generated/flex/flex_grow_height_maximized.rs +++ b/tests/generated/flex/flex_grow_height_maximized.rs @@ -6,6 +6,7 @@ fn flex_grow_height_maximized__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -13,6 +14,7 @@ fn flex_grow_height_maximized__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn flex_grow_height_maximized__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -33,6 +39,10 @@ fn flex_grow_height_maximized__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(500f32), @@ -46,30 +56,182 @@ fn flex_grow_height_maximized__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node00, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 400f32, "y of node {:?}. Expected {}. Actual {}", node01, 400f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 400f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,6 +243,7 @@ fn flex_grow_height_maximized__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -89,6 +252,7 @@ fn flex_grow_height_maximized__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -98,6 +262,10 @@ fn flex_grow_height_maximized__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -111,6 +279,10 @@ fn flex_grow_height_maximized__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(500f32), @@ -124,28 +296,180 @@ fn flex_grow_height_maximized__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 500f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node00, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 400f32, "y of node {:?}. Expected {}. Actual {}", node01, 400f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 400f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_in_at_most_container.rs b/tests/generated/flex/flex_grow_in_at_most_container.rs index 169041e47..3eddb49be 100644 --- a/tests/generated/flex/flex_grow_in_at_most_container.rs +++ b/tests/generated/flex/flex_grow_in_at_most_container.rs @@ -6,15 +6,31 @@ fn flex_grow_in_at_most_container__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() }) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,24 +45,125 @@ fn flex_grow_in_at_most_container__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +175,7 @@ fn flex_grow_in_at_most_container__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -65,7 +183,14 @@ fn flex_grow_in_at_most_container__content_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -73,6 +198,10 @@ fn flex_grow_in_at_most_container__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -87,22 +216,123 @@ fn flex_grow_in_at_most_container__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_less_than_factor_one.rs b/tests/generated/flex/flex_grow_less_than_factor_one.rs index 45ff95529..bc496392b 100644 --- a/tests/generated/flex/flex_grow_less_than_factor_one.rs +++ b/tests/generated/flex/flex_grow_less_than_factor_one.rs @@ -6,19 +6,36 @@ fn flex_grow_less_than_factor_one__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.2f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(40f32), ..Default::default() }) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); - let node2 = - taffy.new_leaf(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 0.2f32, + flex_shrink: 0f32, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 0.4f32, + flex_shrink: 0f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(200f32), @@ -32,30 +49,182 @@ fn flex_grow_less_than_factor_one__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 132f32, "width of node {:?}. Expected {}. Actual {}", node0, 132f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 132f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node1, 92f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node1, 132f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 92f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 132f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node2, 184f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node2, 200f32, size.height); - assert_eq!(location.x, 224f32, "x of node {:?}. Expected {}. Actual {}", node2, 224f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 224f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 224f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +236,7 @@ fn flex_grow_less_than_factor_one__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.2f32, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(40f32), @@ -76,6 +246,7 @@ fn flex_grow_less_than_factor_one__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() @@ -84,6 +255,7 @@ fn flex_grow_less_than_factor_one__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() @@ -93,6 +265,10 @@ fn flex_grow_less_than_factor_one__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(200f32), @@ -106,28 +282,180 @@ fn flex_grow_less_than_factor_one__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 132f32, "width of node {:?}. Expected {}. Actual {}", node0, 132f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 132f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node1, 92f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node1, 132f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 92f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 132f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node2, 184f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node2, 200f32, size.height); - assert_eq!(location.x, 224f32, "x of node {:?}. Expected {}. Actual {}", node2, 224f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 184f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 184f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 224f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 224f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_root_minimized.rs b/tests/generated/flex/flex_grow_root_minimized.rs index d09f5c8ba..248208da2 100644 --- a/tests/generated/flex/flex_grow_root_minimized.rs +++ b/tests/generated/flex/flex_grow_root_minimized.rs @@ -6,6 +6,7 @@ fn flex_grow_root_minimized__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -13,6 +14,7 @@ fn flex_grow_root_minimized__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn flex_grow_root_minimized__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -33,6 +39,10 @@ fn flex_grow_root_minimized__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -45,30 +55,182 @@ fn flex_grow_root_minimized__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node0, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node01, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +242,7 @@ fn flex_grow_root_minimized__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -88,6 +251,7 @@ fn flex_grow_root_minimized__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -97,6 +261,10 @@ fn flex_grow_root_minimized__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -110,6 +278,10 @@ fn flex_grow_root_minimized__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -122,28 +294,180 @@ fn flex_grow_root_minimized__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node0, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node01, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_shrink_at_most.rs b/tests/generated/flex/flex_grow_shrink_at_most.rs index 2869417e6..83ed4ef2e 100644 --- a/tests/generated/flex/flex_grow_shrink_at_most.rs +++ b/tests/generated/flex/flex_grow_shrink_at_most.rs @@ -4,12 +4,33 @@ fn flex_grow_shrink_at_most__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -23,24 +44,137 @@ fn flex_grow_shrink_at_most__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +186,7 @@ fn flex_grow_shrink_at_most__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -59,7 +194,14 @@ fn flex_grow_shrink_at_most__content_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -67,6 +209,10 @@ fn flex_grow_shrink_at_most__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,22 +226,135 @@ fn flex_grow_shrink_at_most__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_to_min.rs b/tests/generated/flex/flex_grow_to_min.rs index fd8227502..02354b4d4 100644 --- a/tests/generated/flex/flex_grow_to_min.rs +++ b/tests/generated/flex/flex_grow_to_min.rs @@ -4,10 +4,17 @@ fn flex_grow_to_min__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -16,6 +23,10 @@ fn flex_grow_to_min__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -28,24 +39,125 @@ fn flex_grow_to_min__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +169,7 @@ fn flex_grow_to_min__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -65,6 +178,7 @@ fn flex_grow_to_min__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -74,6 +188,10 @@ fn flex_grow_to_min__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -86,22 +204,123 @@ fn flex_grow_to_min__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_max_column.rs b/tests/generated/flex/flex_grow_within_constrained_max_column.rs index e15487492..742b1a591 100644 --- a/tests/generated/flex/flex_grow_within_constrained_max_column.rs +++ b/tests/generated/flex/flex_grow_within_constrained_max_column.rs @@ -6,6 +6,7 @@ fn flex_grow_within_constrained_max_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() @@ -13,6 +14,7 @@ fn flex_grow_within_constrained_max_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn flex_grow_within_constrained_max_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -32,24 +38,125 @@ fn flex_grow_within_constrained_max_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +168,7 @@ fn flex_grow_within_constrained_max_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() @@ -69,6 +177,7 @@ fn flex_grow_within_constrained_max_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -78,6 +187,10 @@ fn flex_grow_within_constrained_max_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -89,22 +202,123 @@ fn flex_grow_within_constrained_max_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_max_row.rs b/tests/generated/flex/flex_grow_within_constrained_max_row.rs index 35c28306c..8f284dda9 100644 --- a/tests/generated/flex/flex_grow_within_constrained_max_row.rs +++ b/tests/generated/flex/flex_grow_within_constrained_max_row.rs @@ -6,6 +6,7 @@ fn flex_grow_within_constrained_max_row__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() @@ -13,6 +14,7 @@ fn flex_grow_within_constrained_max_row__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -20,6 +22,10 @@ fn flex_grow_within_constrained_max_row__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -31,6 +37,10 @@ fn flex_grow_within_constrained_max_row__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -41,30 +51,182 @@ fn flex_grow_within_constrained_max_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node00, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node01, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node01, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -76,6 +238,7 @@ fn flex_grow_within_constrained_max_row__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() @@ -84,6 +247,7 @@ fn flex_grow_within_constrained_max_row__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -92,6 +256,10 @@ fn flex_grow_within_constrained_max_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -104,6 +272,10 @@ fn flex_grow_within_constrained_max_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -114,28 +286,180 @@ fn flex_grow_within_constrained_max_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node00, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node01, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node01, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_max_width.rs b/tests/generated/flex/flex_grow_within_constrained_max_width.rs index 71f7134c8..2deda7c5c 100644 --- a/tests/generated/flex/flex_grow_within_constrained_max_width.rs +++ b/tests/generated/flex/flex_grow_within_constrained_max_width.rs @@ -6,6 +6,7 @@ fn flex_grow_within_constrained_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -14,6 +15,10 @@ fn flex_grow_within_constrained_max_width__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn flex_grow_within_constrained_max_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,24 +46,131 @@ fn flex_grow_within_constrained_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +182,7 @@ fn flex_grow_within_constrained_max_width__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -75,6 +192,10 @@ fn flex_grow_within_constrained_max_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() }, @@ -86,6 +207,10 @@ fn flex_grow_within_constrained_max_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -99,22 +224,129 @@ fn flex_grow_within_constrained_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_min_column.rs b/tests/generated/flex/flex_grow_within_constrained_min_column.rs index 2685097ca..2bb9d3b2a 100644 --- a/tests/generated/flex/flex_grow_within_constrained_min_column.rs +++ b/tests/generated/flex/flex_grow_within_constrained_min_column.rs @@ -4,9 +4,16 @@ fn flex_grow_within_constrained_min_column__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -15,6 +22,10 @@ fn flex_grow_within_constrained_min_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -25,24 +36,125 @@ fn flex_grow_within_constrained_min_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +166,7 @@ fn flex_grow_within_constrained_min_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -61,6 +174,7 @@ fn flex_grow_within_constrained_min_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -70,6 +184,10 @@ fn flex_grow_within_constrained_min_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }, @@ -80,22 +198,123 @@ fn flex_grow_within_constrained_min_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_min_max_column.rs b/tests/generated/flex/flex_grow_within_constrained_min_max_column.rs index 53a088c11..23c792ca6 100644 --- a/tests/generated/flex/flex_grow_within_constrained_min_max_column.rs +++ b/tests/generated/flex/flex_grow_within_constrained_min_max_column.rs @@ -4,9 +4,16 @@ fn flex_grow_within_constrained_min_max_column__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -15,6 +22,10 @@ fn flex_grow_within_constrained_min_max_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -26,24 +37,125 @@ fn flex_grow_within_constrained_min_max_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +167,7 @@ fn flex_grow_within_constrained_min_max_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -62,6 +175,7 @@ fn flex_grow_within_constrained_min_max_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) @@ -71,6 +185,10 @@ fn flex_grow_within_constrained_min_max_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -82,22 +200,123 @@ fn flex_grow_within_constrained_min_max_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_constrained_min_row.rs b/tests/generated/flex/flex_grow_within_constrained_min_row.rs index b15c05ed7..c1a4c54f9 100644 --- a/tests/generated/flex/flex_grow_within_constrained_min_row.rs +++ b/tests/generated/flex/flex_grow_within_constrained_min_row.rs @@ -4,9 +4,16 @@ fn flex_grow_within_constrained_min_row__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -14,6 +21,10 @@ fn flex_grow_within_constrained_min_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -25,24 +36,137 @@ fn flex_grow_within_constrained_min_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +178,7 @@ fn flex_grow_within_constrained_min_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -61,6 +186,7 @@ fn flex_grow_within_constrained_min_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -69,6 +195,10 @@ fn flex_grow_within_constrained_min_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -80,22 +210,135 @@ fn flex_grow_within_constrained_min_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_grow_within_max_width.rs b/tests/generated/flex/flex_grow_within_max_width.rs index 3eacaa036..7febfd819 100644 --- a/tests/generated/flex/flex_grow_within_max_width.rs +++ b/tests/generated/flex/flex_grow_within_max_width.rs @@ -6,6 +6,7 @@ fn flex_grow_within_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -14,6 +15,10 @@ fn flex_grow_within_max_width__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -24,6 +29,10 @@ fn flex_grow_within_max_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,24 +46,131 @@ fn flex_grow_within_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +182,7 @@ fn flex_grow_within_max_width__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() @@ -75,6 +192,10 @@ fn flex_grow_within_max_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -86,6 +207,10 @@ fn flex_grow_within_max_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -99,22 +224,129 @@ fn flex_grow_within_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_inflow_overflow_clip.rs b/tests/generated/flex/flex_inflow_overflow_clip.rs new file mode 100644 index 000000000..207ca56f1 --- /dev/null +++ b/tests/generated/flex/flex_inflow_overflow_clip.rs @@ -0,0 +1,279 @@ +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_inflow_overflow_hidden.rs b/tests/generated/flex/flex_inflow_overflow_hidden.rs new file mode 100644 index 000000000..26d9b37b2 --- /dev/null +++ b/tests/generated/flex/flex_inflow_overflow_hidden.rs @@ -0,0 +1,287 @@ +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 64f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 64f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_inflow_overflow_scroll.rs b/tests/generated/flex/flex_inflow_overflow_scroll.rs new file mode 100644 index 000000000..14d5bb360 --- /dev/null +++ b/tests/generated/flex/flex_inflow_overflow_scroll.rs @@ -0,0 +1,287 @@ +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 79f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 79f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 13f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 65f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_inflow_overflow_visible.rs b/tests/generated/flex/flex_inflow_overflow_visible.rs new file mode 100644 index 000000000..fbf6e7903 --- /dev/null +++ b/tests/generated/flex/flex_inflow_overflow_visible.rs @@ -0,0 +1,285 @@ +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn flex_inflow_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/flex/flex_root_ignored.rs b/tests/generated/flex/flex_root_ignored.rs index 473afe243..a57020e1e 100644 --- a/tests/generated/flex/flex_root_ignored.rs +++ b/tests/generated/flex/flex_root_ignored.rs @@ -6,6 +6,7 @@ fn flex_root_ignored__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -13,6 +14,7 @@ fn flex_root_ignored__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -21,6 +23,10 @@ fn flex_root_ignored__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -33,24 +39,137 @@ fn flex_root_ignored__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +181,7 @@ fn flex_root_ignored__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(200f32), ..Default::default() @@ -70,6 +190,7 @@ fn flex_root_ignored__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) @@ -79,6 +200,10 @@ fn flex_root_ignored__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) }, @@ -91,22 +216,135 @@ fn flex_root_ignored__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_row_relative_all_sides.rs b/tests/generated/flex/flex_row_relative_all_sides.rs index 6a066db34..b9a6e475b 100644 --- a/tests/generated/flex/flex_row_relative_all_sides.rs +++ b/tests/generated/flex/flex_row_relative_all_sides.rs @@ -6,6 +6,7 @@ fn flex_row_relative_all_sides__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -19,6 +20,10 @@ fn flex_row_relative_all_sides__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,92 @@ fn flex_row_relative_all_sides__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +134,7 @@ fn flex_row_relative_all_sides__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -69,6 +149,10 @@ fn flex_row_relative_all_sides__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +166,90 @@ fn flex_row_relative_all_sides__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs b/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs index d3fe04d59..3ebfdb4a6 100644 --- a/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs +++ b/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs @@ -6,6 +6,7 @@ fn flex_shrink_by_outer_margin_with_max_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn flex_shrink_by_outer_margin_with_max_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, ..Default::default() @@ -29,18 +34,86 @@ fn flex_shrink_by_outer_margin_with_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn flex_shrink_by_outer_margin_with_max_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -65,6 +139,10 @@ fn flex_shrink_by_outer_margin_with_max_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, ..Default::default() @@ -76,16 +154,84 @@ fn flex_shrink_by_outer_margin_with_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs index 438bd9b85..089da6fe2 100644 --- a/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs +++ b/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -6,6 +6,7 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -29,6 +31,10 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -42,24 +48,137 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +190,7 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -83,6 +203,7 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -96,6 +217,10 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -109,22 +234,135 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_shrink_flex_grow_row.rs b/tests/generated/flex/flex_shrink_flex_grow_row.rs index 6ced3faf1..9a68a8894 100644 --- a/tests/generated/flex/flex_shrink_flex_grow_row.rs +++ b/tests/generated/flex/flex_shrink_flex_grow_row.rs @@ -6,6 +6,7 @@ fn flex_shrink_flex_grow_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn flex_shrink_flex_grow_row__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -29,6 +31,10 @@ fn flex_shrink_flex_grow_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -42,24 +48,137 @@ fn flex_shrink_flex_grow_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +190,7 @@ fn flex_shrink_flex_grow_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -83,6 +203,7 @@ fn flex_shrink_flex_grow_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0f32, flex_shrink: 1f32, size: taffy::geometry::Size { @@ -96,6 +217,10 @@ fn flex_shrink_flex_grow_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -109,22 +234,135 @@ fn flex_shrink_flex_grow_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_shrink_to_zero.rs b/tests/generated/flex/flex_shrink_to_zero.rs index 7c87a1bc3..ea9f4757c 100644 --- a/tests/generated/flex/flex_shrink_to_zero.rs +++ b/tests/generated/flex/flex_shrink_to_zero.rs @@ -6,6 +6,7 @@ fn flex_shrink_to_zero__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -16,6 +17,7 @@ fn flex_shrink_to_zero__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -26,6 +28,7 @@ fn flex_shrink_to_zero__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -37,6 +40,10 @@ fn flex_shrink_to_zero__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(75f32), height: auto() }, ..Default::default() }, @@ -47,30 +54,164 @@ fn flex_shrink_to_zero__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node, 75f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 25f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,6 +223,7 @@ fn flex_shrink_to_zero__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -93,6 +235,7 @@ fn flex_shrink_to_zero__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -104,6 +247,7 @@ fn flex_shrink_to_zero__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -116,6 +260,10 @@ fn flex_shrink_to_zero__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(75f32), height: auto() }, ..Default::default() }, @@ -126,28 +274,162 @@ fn flex_shrink_to_zero__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node, 75f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 25f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs b/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs index 345bf6440..e40cb77f5 100644 --- a/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs +++ b/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs @@ -6,12 +6,14 @@ fn flex_wrap_align_stretch_fits_one_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -20,6 +22,10 @@ fn flex_wrap_align_stretch_fits_one_row__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,24 +39,137 @@ fn flex_wrap_align_stretch_fits_one_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +181,7 @@ fn flex_wrap_align_stretch_fits_one_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -69,6 +189,7 @@ fn flex_wrap_align_stretch_fits_one_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) @@ -78,6 +199,10 @@ fn flex_wrap_align_stretch_fits_one_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(100f32), @@ -91,22 +216,135 @@ fn flex_wrap_align_stretch_fits_one_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.rs index 58f819e75..27979854c 100644 --- a/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.rs +++ b/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -6,6 +6,7 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(55f32), height: auto() }, @@ -14,6 +15,7 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(55f32), height: auto() }, @@ -24,6 +26,10 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -34,24 +40,125 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node1, 55f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +170,7 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(55f32), height: auto() }, @@ -72,6 +180,7 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(55f32), height: auto() }, @@ -83,6 +192,10 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -93,22 +206,123 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node1, 55f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); + if layout.size.width != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 55f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/flex_wrap_wrap_to_child_height.rs b/tests/generated/flex/flex_wrap_wrap_to_child_height.rs index 12000f2a7..d0fe13b6d 100644 --- a/tests/generated/flex/flex_wrap_wrap_to_child_height.rs +++ b/tests/generated/flex/flex_wrap_wrap_to_child_height.rs @@ -6,6 +6,7 @@ fn flex_wrap_wrap_to_child_height__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn flex_wrap_wrap_to_child_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -27,6 +32,10 @@ fn flex_wrap_wrap_to_child_height__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, @@ -35,6 +44,7 @@ fn flex_wrap_wrap_to_child_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -44,7 +54,14 @@ fn flex_wrap_wrap_to_child_height__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -52,36 +69,233 @@ fn flex_wrap_wrap_to_child_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node000, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 100f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -93,6 +307,7 @@ fn flex_wrap_wrap_to_child_height__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -105,6 +320,10 @@ fn flex_wrap_wrap_to_child_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -116,6 +335,10 @@ fn flex_wrap_wrap_to_child_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, @@ -125,6 +348,7 @@ fn flex_wrap_wrap_to_child_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -137,6 +361,10 @@ fn flex_wrap_wrap_to_child_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -146,34 +374,231 @@ fn flex_wrap_wrap_to_child_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node000, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 100f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_child_margins.rs b/tests/generated/flex/gap_column_gap_child_margins.rs index 88bcdf7fa..fb84f3597 100644 --- a/tests/generated/flex/gap_column_gap_child_margins.rs +++ b/tests/generated/flex/gap_column_gap_child_margins.rs @@ -6,6 +6,7 @@ fn gap_column_gap_child_margins__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -15,6 +16,7 @@ fn gap_column_gap_child_margins__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -24,6 +26,7 @@ fn gap_column_gap_child_margins__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -34,6 +37,10 @@ fn gap_column_gap_child_margins__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -48,30 +55,182 @@ fn gap_column_gap_child_margins__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 26f32, "x of node {:?}. Expected {}. Actual {}", node1, 26f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 26f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node2, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -83,6 +242,7 @@ fn gap_column_gap_child_margins__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -93,6 +253,7 @@ fn gap_column_gap_child_margins__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -103,6 +264,7 @@ fn gap_column_gap_child_margins__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -114,6 +276,10 @@ fn gap_column_gap_child_margins__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -128,28 +294,180 @@ fn gap_column_gap_child_margins__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 26f32, "x of node {:?}. Expected {}. Actual {}", node1, 26f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 26f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node2, 2f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_determines_parent_width.rs b/tests/generated/flex/gap_column_gap_determines_parent_width.rs index f05975f51..e93a474c9 100644 --- a/tests/generated/flex/gap_column_gap_determines_parent_width.rs +++ b/tests/generated/flex/gap_column_gap_determines_parent_width.rs @@ -6,18 +6,21 @@ fn gap_column_gap_determines_parent_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_determines_parent_width__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -37,30 +44,182 @@ fn gap_column_gap_determines_parent_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,6 +231,7 @@ fn gap_column_gap_determines_parent_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -79,6 +239,7 @@ fn gap_column_gap_determines_parent_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -86,6 +247,7 @@ fn gap_column_gap_determines_parent_width__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: auto() }, ..Default::default() }) @@ -94,6 +256,10 @@ fn gap_column_gap_determines_parent_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -106,28 +272,180 @@ fn gap_column_gap_determines_parent_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_flexible.rs b/tests/generated/flex/gap_column_gap_flexible.rs index 4f1e26453..6899196a9 100644 --- a/tests/generated/flex/gap_column_gap_flexible.rs +++ b/tests/generated/flex/gap_column_gap_flexible.rs @@ -6,6 +6,7 @@ fn gap_column_gap_flexible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -14,6 +15,7 @@ fn gap_column_gap_flexible__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -22,6 +24,7 @@ fn gap_column_gap_flexible__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -31,6 +34,10 @@ fn gap_column_gap_flexible__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -45,30 +52,182 @@ fn gap_column_gap_flexible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn gap_column_gap_flexible__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -89,6 +249,7 @@ fn gap_column_gap_flexible__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -98,6 +259,7 @@ fn gap_column_gap_flexible__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -108,6 +270,10 @@ fn gap_column_gap_flexible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -122,28 +288,180 @@ fn gap_column_gap_flexible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_flexible_undefined_parent.rs b/tests/generated/flex/gap_column_gap_flexible_undefined_parent.rs index 37e14f67c..2cbdabab9 100644 --- a/tests/generated/flex/gap_column_gap_flexible_undefined_parent.rs +++ b/tests/generated/flex/gap_column_gap_flexible_undefined_parent.rs @@ -6,6 +6,7 @@ fn gap_column_gap_flexible_undefined_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -14,6 +15,7 @@ fn gap_column_gap_flexible_undefined_parent__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -22,6 +24,7 @@ fn gap_column_gap_flexible_undefined_parent__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -31,6 +34,10 @@ fn gap_column_gap_flexible_undefined_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -42,30 +49,182 @@ fn gap_column_gap_flexible_undefined_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +236,7 @@ fn gap_column_gap_flexible_undefined_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -86,6 +246,7 @@ fn gap_column_gap_flexible_undefined_parent__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -95,6 +256,7 @@ fn gap_column_gap_flexible_undefined_parent__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -105,6 +267,10 @@ fn gap_column_gap_flexible_undefined_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -116,28 +282,180 @@ fn gap_column_gap_flexible_undefined_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_inflexible.rs b/tests/generated/flex/gap_column_gap_inflexible.rs index 3c6547173..4515796ac 100644 --- a/tests/generated/flex/gap_column_gap_inflexible.rs +++ b/tests/generated/flex/gap_column_gap_inflexible.rs @@ -6,18 +6,21 @@ fn gap_column_gap_inflexible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_inflexible__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -39,30 +46,182 @@ fn gap_column_gap_inflexible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn gap_column_gap_inflexible__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn gap_column_gap_inflexible__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn gap_column_gap_inflexible__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn gap_column_gap_inflexible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -110,28 +276,180 @@ fn gap_column_gap_inflexible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs b/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs index bda2940e1..02259c8c8 100644 --- a/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs +++ b/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs @@ -6,18 +6,21 @@ fn gap_column_gap_inflexible_undefined_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_inflexible_undefined_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -36,30 +43,182 @@ fn gap_column_gap_inflexible_undefined_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,6 +230,7 @@ fn gap_column_gap_inflexible_undefined_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -78,6 +238,7 @@ fn gap_column_gap_inflexible_undefined_parent__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -85,6 +246,7 @@ fn gap_column_gap_inflexible_undefined_parent__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -93,6 +255,10 @@ fn gap_column_gap_inflexible_undefined_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -104,28 +270,180 @@ fn gap_column_gap_inflexible_undefined_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_center.rs b/tests/generated/flex/gap_column_gap_justify_center.rs index 098794257..e5b52efed 100644 --- a/tests/generated/flex/gap_column_gap_justify_center.rs +++ b/tests/generated/flex/gap_column_gap_justify_center.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_flex_end.rs b/tests/generated/flex/gap_column_gap_justify_flex_end.rs index 1b351f296..e7e29d110 100644 --- a/tests/generated/flex/gap_column_gap_justify_flex_end.rs +++ b/tests/generated/flex/gap_column_gap_justify_flex_end.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_flex_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_flex_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_flex_start.rs b/tests/generated/flex/gap_column_gap_justify_flex_start.rs index ee3401071..b8de298ed 100644 --- a/tests/generated/flex/gap_column_gap_justify_flex_start.rs +++ b/tests/generated/flex/gap_column_gap_justify_flex_start.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_flex_start__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_flex_start__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_space_around.rs b/tests/generated/flex/gap_column_gap_justify_space_around.rs index 927b748b6..73bc410d1 100644 --- a/tests/generated/flex/gap_column_gap_justify_space_around.rs +++ b/tests/generated/flex/gap_column_gap_justify_space_around.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_space_around__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_space_around__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 3f32, "x of node {:?}. Expected {}. Actual {}", node0, 3f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 3f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 77f32, "x of node {:?}. Expected {}. Actual {}", node2, 77f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 77f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 77f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_space_around__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_space_around__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_space_around__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_space_around__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 3f32, "x of node {:?}. Expected {}. Actual {}", node0, 3f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 3f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 77f32, "x of node {:?}. Expected {}. Actual {}", node2, 77f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 77f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 77f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_space_between.rs b/tests/generated/flex/gap_column_gap_justify_space_between.rs index 8d665b2cc..8185de16c 100644 --- a/tests/generated/flex/gap_column_gap_justify_space_between.rs +++ b/tests/generated/flex/gap_column_gap_justify_space_between.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_space_between__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_space_between__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_space_between__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_space_between__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_space_between__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_space_between__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_justify_space_evenly.rs b/tests/generated/flex/gap_column_gap_justify_space_evenly.rs index 5706f0c72..be11cec4b 100644 --- a/tests/generated/flex/gap_column_gap_justify_space_evenly.rs +++ b/tests/generated/flex/gap_column_gap_justify_space_evenly.rs @@ -6,18 +6,21 @@ fn gap_column_gap_justify_space_evenly__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_justify_space_evenly__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -40,30 +47,182 @@ fn gap_column_gap_justify_space_evenly__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +234,7 @@ fn gap_column_gap_justify_space_evenly__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -82,6 +242,7 @@ fn gap_column_gap_justify_space_evenly__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -89,6 +250,7 @@ fn gap_column_gap_justify_space_evenly__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -97,6 +259,10 @@ fn gap_column_gap_justify_space_evenly__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { @@ -112,28 +278,180 @@ fn gap_column_gap_justify_space_evenly__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_mixed_flexible.rs b/tests/generated/flex/gap_column_gap_mixed_flexible.rs index f91104853..69469a6ae 100644 --- a/tests/generated/flex/gap_column_gap_mixed_flexible.rs +++ b/tests/generated/flex/gap_column_gap_mixed_flexible.rs @@ -6,12 +6,14 @@ fn gap_column_gap_mixed_flexible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -20,6 +22,7 @@ fn gap_column_gap_mixed_flexible__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -27,6 +30,10 @@ fn gap_column_gap_mixed_flexible__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -41,30 +48,182 @@ fn gap_column_gap_mixed_flexible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -76,6 +235,7 @@ fn gap_column_gap_mixed_flexible__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -83,6 +243,7 @@ fn gap_column_gap_mixed_flexible__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -92,6 +253,7 @@ fn gap_column_gap_mixed_flexible__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -100,6 +262,10 @@ fn gap_column_gap_mixed_flexible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), @@ -114,28 +280,180 @@ fn gap_column_gap_mixed_flexible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs b/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs index 7b3ce7f57..54cb950dc 100644 --- a/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs +++ b/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs @@ -6,6 +6,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -25,6 +27,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -36,6 +39,10 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.5f32), height: zero() }, ..Default::default() }, @@ -46,30 +53,164 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 40f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,6 +222,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -92,6 +234,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -102,6 +245,7 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -114,6 +258,10 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.5f32), height: zero() }, ..Default::default() }, @@ -124,28 +272,162 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 40f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs b/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs index 77bd05bd5..b4e420edb 100644 --- a/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs +++ b/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs @@ -6,6 +6,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -15,6 +16,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -24,6 +26,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -34,6 +37,10 @@ fn gap_column_gap_percentage_cyclic_shrinkable__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, ..Default::default() }, @@ -44,30 +51,164 @@ fn gap_column_gap_percentage_cyclic_shrinkable__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node1, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node1, 24f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 24f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node2, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node2, 48f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +220,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -89,6 +231,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -99,6 +242,7 @@ fn gap_column_gap_percentage_cyclic_shrinkable__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(40f32), @@ -110,6 +254,10 @@ fn gap_column_gap_percentage_cyclic_shrinkable__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, ..Default::default() }, @@ -120,28 +268,162 @@ fn gap_column_gap_percentage_cyclic_shrinkable__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node1, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node1, 24f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 24f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node2, 12f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node2, 48f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs b/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs index 315f0682b..e7d3790f9 100644 --- a/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs +++ b/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs @@ -6,6 +6,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -26,6 +28,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -37,6 +40,10 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, ..Default::default() }, @@ -47,30 +54,164 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 24f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node1, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 64f32, "x of node {:?}. Expected {}. Actual {}", node2, 64f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 64f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,6 +223,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -93,6 +235,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -104,6 +247,7 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -116,6 +260,10 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, ..Default::default() }, @@ -126,28 +274,162 @@ fn gap_column_gap_percentage_cyclic_unshrinkable__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 24f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node1, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 64f32, "x of node {:?}. Expected {}. Actual {}", node2, 64f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 64f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_flexible.rs b/tests/generated/flex/gap_column_gap_percentage_flexible.rs index 3c2e3ee76..63c8db712 100644 --- a/tests/generated/flex/gap_column_gap_percentage_flexible.rs +++ b/tests/generated/flex/gap_column_gap_percentage_flexible.rs @@ -6,6 +6,7 @@ fn gap_column_gap_percentage_flexible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -14,6 +15,7 @@ fn gap_column_gap_percentage_flexible__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -22,6 +24,7 @@ fn gap_column_gap_percentage_flexible__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -31,6 +34,10 @@ fn gap_column_gap_percentage_flexible__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.1f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -45,30 +52,182 @@ fn gap_column_gap_percentage_flexible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node0, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 26f32, "width of node {:?}. Expected {}. Actual {}", node1, 26f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 37f32, "x of node {:?}. Expected {}. Actual {}", node1, 37f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 26f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 37f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node2, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 73f32, "x of node {:?}. Expected {}. Actual {}", node2, 73f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 73f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +239,7 @@ fn gap_column_gap_percentage_flexible__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -89,6 +249,7 @@ fn gap_column_gap_percentage_flexible__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -98,6 +259,7 @@ fn gap_column_gap_percentage_flexible__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -108,6 +270,10 @@ fn gap_column_gap_percentage_flexible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.1f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -122,28 +288,180 @@ fn gap_column_gap_percentage_flexible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node0, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 26f32, "width of node {:?}. Expected {}. Actual {}", node1, 26f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 37f32, "x of node {:?}. Expected {}. Actual {}", node1, 37f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 26f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 37f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 37f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node2, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 73f32, "x of node {:?}. Expected {}. Actual {}", node2, 73f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 73f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.rs b/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.rs index b7d258638..50543a7b2 100644 --- a/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.rs +++ b/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.rs @@ -6,6 +6,7 @@ fn gap_column_gap_percentage_flexible_with_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -14,6 +15,7 @@ fn gap_column_gap_percentage_flexible_with_padding__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -22,6 +24,7 @@ fn gap_column_gap_percentage_flexible_with_padding__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -31,6 +34,10 @@ fn gap_column_gap_percentage_flexible_with_padding__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.1f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -51,30 +58,164 @@ fn gap_column_gap_percentage_flexible_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 21f32, "width of node {:?}. Expected {}. Actual {}", node0, 21f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 21f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1, 22f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 39f32, "x of node {:?}. Expected {}. Actual {}", node1, 39f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 39f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 39f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 21f32, "width of node {:?}. Expected {}. Actual {}", node2, 21f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height); - assert_eq!(location.x, 69f32, "x of node {:?}. Expected {}. Actual {}", node2, 69f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 21f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 21f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 69f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 69f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,6 +227,7 @@ fn gap_column_gap_percentage_flexible_with_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -95,6 +237,7 @@ fn gap_column_gap_percentage_flexible_with_padding__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -104,6 +247,7 @@ fn gap_column_gap_percentage_flexible_with_padding__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -114,6 +258,10 @@ fn gap_column_gap_percentage_flexible_with_padding__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.1f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -134,28 +282,180 @@ fn gap_column_gap_percentage_flexible_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node0, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 26f32, "width of node {:?}. Expected {}. Actual {}", node1, 26f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 47f32, "x of node {:?}. Expected {}. Actual {}", node1, 47f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 26f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 47f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 47f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node2, 27f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 83f32, "x of node {:?}. Expected {}. Actual {}", node2, 83f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 27f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 83f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 83f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_percentage_inflexible.rs b/tests/generated/flex/gap_column_gap_percentage_inflexible.rs index 27e1c2e2d..43e1f7149 100644 --- a/tests/generated/flex/gap_column_gap_percentage_inflexible.rs +++ b/tests/generated/flex/gap_column_gap_percentage_inflexible.rs @@ -6,18 +6,21 @@ fn gap_column_gap_percentage_inflexible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn gap_column_gap_percentage_inflexible__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn gap_column_gap_percentage_inflexible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn gap_column_gap_percentage_inflexible__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn gap_column_gap_percentage_inflexible__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn gap_column_gap_percentage_inflexible__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn gap_column_gap_percentage_inflexible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn gap_column_gap_percentage_inflexible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs b/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs index 6621fe530..d04355e55 100644 --- a/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs +++ b/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs @@ -6,6 +6,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -60,6 +66,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -69,6 +76,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -78,6 +86,7 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .unwrap(); let node8 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +98,10 @@ fn gap_column_gap_row_gap_wrapping__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -100,66 +113,398 @@ fn gap_column_gap_row_gap_wrapping__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -171,6 +516,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -181,6 +527,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -191,6 +538,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -201,6 +549,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -211,6 +560,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -221,6 +571,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -231,6 +582,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -241,6 +593,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -251,6 +604,7 @@ fn gap_column_gap_row_gap_wrapping__content_box() { let node8 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -263,6 +617,10 @@ fn gap_column_gap_row_gap_wrapping__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -274,64 +632,396 @@ fn gap_column_gap_row_gap_wrapping__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_start_index.rs b/tests/generated/flex/gap_column_gap_start_index.rs index c33af18a3..8b2bebf9e 100644 --- a/tests/generated/flex/gap_column_gap_start_index.rs +++ b/tests/generated/flex/gap_column_gap_start_index.rs @@ -7,6 +7,7 @@ fn gap_column_gap_start_index__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn gap_column_gap_start_index__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -25,6 +27,7 @@ fn gap_column_gap_start_index__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -34,6 +37,7 @@ fn gap_column_gap_start_index__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -45,6 +49,10 @@ fn gap_column_gap_start_index__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -56,36 +64,203 @@ fn gap_column_gap_start_index__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node2, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +273,7 @@ fn gap_column_gap_start_index__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -108,6 +284,7 @@ fn gap_column_gap_start_index__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -118,6 +295,7 @@ fn gap_column_gap_start_index__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -128,6 +306,7 @@ fn gap_column_gap_start_index__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +319,10 @@ fn gap_column_gap_start_index__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -151,34 +334,201 @@ fn gap_column_gap_start_index__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node2, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_center.rs b/tests/generated/flex/gap_column_gap_wrap_align_center.rs index d637b776a..ee66aadce 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_center.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_center.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_wrap_align_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_wrap_align_center__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_wrap_align_center__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_wrap_align_center__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_wrap_align_center__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -62,6 +68,10 @@ fn gap_column_gap_wrap_align_center__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -77,48 +87,281 @@ fn gap_column_gap_wrap_align_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node5, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +373,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +384,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +395,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +406,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -170,6 +417,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -180,6 +428,7 @@ fn gap_column_gap_wrap_align_center__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,6 +441,10 @@ fn gap_column_gap_wrap_align_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -207,46 +460,279 @@ fn gap_column_gap_wrap_align_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node5, 60f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs b/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs index 105978f73..7584fc771 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -62,6 +68,10 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -77,48 +87,281 @@ fn gap_column_gap_wrap_align_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +373,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +384,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +395,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +406,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -170,6 +417,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -180,6 +428,7 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,6 +441,10 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -207,46 +460,279 @@ fn gap_column_gap_wrap_align_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs b/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs index 2938fd10c..0dc50b87c 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -62,6 +68,10 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -77,48 +87,281 @@ fn gap_column_gap_wrap_align_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +373,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +384,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +395,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +406,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -170,6 +417,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -180,6 +428,7 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,6 +441,10 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -207,46 +460,279 @@ fn gap_column_gap_wrap_align_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs b/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs index 8a97bee37..66346711a 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -62,6 +68,10 @@ fn gap_column_gap_wrap_align_space_around__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -77,48 +87,281 @@ fn gap_column_gap_wrap_align_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node4, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node5, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +373,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +384,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +395,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +406,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -170,6 +417,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -180,6 +428,7 @@ fn gap_column_gap_wrap_align_space_around__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,6 +441,10 @@ fn gap_column_gap_wrap_align_space_around__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -207,46 +460,279 @@ fn gap_column_gap_wrap_align_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node4, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node5, 70f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs b/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs index 1b5f68d8c..bbcd53eea 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -62,6 +68,10 @@ fn gap_column_gap_wrap_align_space_between__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -77,48 +87,281 @@ fn gap_column_gap_wrap_align_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +373,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -140,6 +384,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -150,6 +395,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -160,6 +406,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -170,6 +417,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -180,6 +428,7 @@ fn gap_column_gap_wrap_align_space_between__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,6 +441,10 @@ fn gap_column_gap_wrap_align_space_between__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -207,46 +460,279 @@ fn gap_column_gap_wrap_align_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs b/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs index b821aa884..03998f6e8 100644 --- a/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs +++ b/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs @@ -6,6 +6,7 @@ fn gap_column_gap_wrap_align_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn gap_column_gap_wrap_align_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -20,6 +22,7 @@ fn gap_column_gap_wrap_align_stretch__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -27,6 +30,7 @@ fn gap_column_gap_wrap_align_stretch__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -34,6 +38,7 @@ fn gap_column_gap_wrap_align_stretch__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -43,6 +48,10 @@ fn gap_column_gap_wrap_align_stretch__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: length(5f32), height: zero() }, size: taffy::geometry::Size { @@ -58,42 +67,272 @@ fn gap_column_gap_wrap_align_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node1, 72f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 76f32, "x of node {:?}. Expected {}. Actual {}", node1, 76f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 76f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 76f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node2, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node2, 150f32, size.height); - assert_eq!(location.x, 153f32, "x of node {:?}. Expected {}. Actual {}", node2, 153f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 153f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 153f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node3, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node3, 150f32, size.height); - assert_eq!(location.x, 229f32, "x of node {:?}. Expected {}. Actual {}", node3, 229f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 229f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 229f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node4, 300f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node4, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node4, 150f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -105,6 +344,7 @@ fn gap_column_gap_wrap_align_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -113,6 +353,7 @@ fn gap_column_gap_wrap_align_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -121,6 +362,7 @@ fn gap_column_gap_wrap_align_stretch__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -129,6 +371,7 @@ fn gap_column_gap_wrap_align_stretch__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -137,6 +380,7 @@ fn gap_column_gap_wrap_align_stretch__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -147,6 +391,10 @@ fn gap_column_gap_wrap_align_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: length(5f32), height: zero() }, size: taffy::geometry::Size { @@ -162,40 +410,270 @@ fn gap_column_gap_wrap_align_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node1, 72f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 76f32, "x of node {:?}. Expected {}. Actual {}", node1, 76f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 76f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 76f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node2, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node2, 150f32, size.height); - assert_eq!(location.x, 153f32, "x of node {:?}. Expected {}. Actual {}", node2, 153f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 153f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 153f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node3, 71f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node3, 150f32, size.height); - assert_eq!(location.x, 229f32, "x of node {:?}. Expected {}. Actual {}", node3, 229f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 229f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 229f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node4, 300f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node4, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node4, 150f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_column_row_gap_wrapping.rs b/tests/generated/flex/gap_column_row_gap_wrapping.rs index 73645318e..00ad45144 100644 --- a/tests/generated/flex/gap_column_row_gap_wrapping.rs +++ b/tests/generated/flex/gap_column_row_gap_wrapping.rs @@ -6,6 +6,7 @@ fn gap_column_row_gap_wrapping__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -60,6 +66,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -69,6 +76,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -78,6 +86,7 @@ fn gap_column_row_gap_wrapping__border_box() { .unwrap(); let node8 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +98,10 @@ fn gap_column_row_gap_wrapping__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -100,66 +113,398 @@ fn gap_column_row_gap_wrapping__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -171,6 +516,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -181,6 +527,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -191,6 +538,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -201,6 +549,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -211,6 +560,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -221,6 +571,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -231,6 +582,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -241,6 +593,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -251,6 +604,7 @@ fn gap_column_row_gap_wrapping__content_box() { let node8 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -263,6 +617,10 @@ fn gap_column_row_gap_wrapping__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -274,64 +632,396 @@ fn gap_column_row_gap_wrapping__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_align_items_end.rs b/tests/generated/flex/gap_row_gap_align_items_end.rs index 96b018f97..74631561a 100644 --- a/tests/generated/flex/gap_row_gap_align_items_end.rs +++ b/tests/generated/flex/gap_row_gap_align_items_end.rs @@ -6,36 +6,42 @@ fn gap_row_gap_align_items_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -44,6 +50,10 @@ fn gap_row_gap_align_items_end__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -59,48 +69,281 @@ fn gap_row_gap_align_items_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +355,7 @@ fn gap_row_gap_align_items_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -119,6 +363,7 @@ fn gap_row_gap_align_items_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -126,6 +371,7 @@ fn gap_row_gap_align_items_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -133,6 +379,7 @@ fn gap_row_gap_align_items_end__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -140,6 +387,7 @@ fn gap_row_gap_align_items_end__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -147,6 +395,7 @@ fn gap_row_gap_align_items_end__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -156,6 +405,10 @@ fn gap_row_gap_align_items_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, size: taffy::geometry::Size { @@ -171,46 +424,279 @@ fn gap_row_gap_align_items_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5, 200f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_align_items_stretch.rs b/tests/generated/flex/gap_row_gap_align_items_stretch.rs index a09ea39a3..1c316730a 100644 --- a/tests/generated/flex/gap_row_gap_align_items_stretch.rs +++ b/tests/generated/flex/gap_row_gap_align_items_stretch.rs @@ -6,36 +6,42 @@ fn gap_row_gap_align_items_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -44,6 +50,10 @@ fn gap_row_gap_align_items_stretch__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, @@ -60,48 +70,281 @@ fn gap_row_gap_align_items_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node3, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node3, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node4, 90f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node4, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node5, 90f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node5, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +356,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -120,6 +364,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -127,6 +372,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -134,6 +380,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -141,6 +388,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -148,6 +396,7 @@ fn gap_row_gap_align_items_stretch__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -157,6 +406,10 @@ fn gap_row_gap_align_items_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: length(10f32), height: length(20f32) }, @@ -173,46 +426,279 @@ fn gap_row_gap_align_items_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node3, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node3, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node4, 90f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node4, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node5, 90f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node5, 110f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 110f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_column_child_margins.rs b/tests/generated/flex/gap_row_gap_column_child_margins.rs index 0e4b4a6c4..b6b4f272e 100644 --- a/tests/generated/flex/gap_row_gap_column_child_margins.rs +++ b/tests/generated/flex/gap_row_gap_column_child_margins.rs @@ -6,6 +6,7 @@ fn gap_row_gap_column_child_margins__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -15,6 +16,7 @@ fn gap_row_gap_column_child_margins__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -24,6 +26,7 @@ fn gap_row_gap_column_child_margins__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -35,6 +38,10 @@ fn gap_row_gap_column_child_margins__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -49,30 +56,164 @@ fn gap_row_gap_column_child_margins__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 66f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 143f32, "y of node {:?}. Expected {}. Actual {}", node2, 143f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 143f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 143f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -84,6 +225,7 @@ fn gap_row_gap_column_child_margins__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -94,6 +236,7 @@ fn gap_row_gap_column_child_margins__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -104,6 +247,7 @@ fn gap_row_gap_column_child_margins__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -116,6 +260,10 @@ fn gap_row_gap_column_child_margins__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -130,28 +278,162 @@ fn gap_row_gap_column_child_margins__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 66f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 143f32, "y of node {:?}. Expected {}. Actual {}", node2, 143f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 143f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 143f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_determines_parent_height.rs b/tests/generated/flex/gap_row_gap_determines_parent_height.rs index 3cb12710f..cdfba133d 100644 --- a/tests/generated/flex/gap_row_gap_determines_parent_height.rs +++ b/tests/generated/flex/gap_row_gap_determines_parent_height.rs @@ -6,18 +6,21 @@ fn gap_row_gap_determines_parent_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(30f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn gap_row_gap_determines_parent_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -38,30 +45,164 @@ fn gap_row_gap_determines_parent_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +214,7 @@ fn gap_row_gap_determines_parent_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -80,6 +222,7 @@ fn gap_row_gap_determines_parent_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) @@ -87,6 +230,7 @@ fn gap_row_gap_determines_parent_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(30f32) }, ..Default::default() }) @@ -96,6 +240,10 @@ fn gap_row_gap_determines_parent_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -108,28 +256,162 @@ fn gap_row_gap_determines_parent_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_percentage_wrapping.rs b/tests/generated/flex/gap_row_gap_percentage_wrapping.rs index f972ade45..aa5e02ce6 100644 --- a/tests/generated/flex/gap_row_gap_percentage_wrapping.rs +++ b/tests/generated/flex/gap_row_gap_percentage_wrapping.rs @@ -6,6 +6,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +36,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +46,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +56,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -60,6 +66,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -69,6 +76,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -78,6 +86,7 @@ fn gap_row_gap_percentage_wrapping__border_box() { .unwrap(); let node8 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -89,6 +98,10 @@ fn gap_row_gap_percentage_wrapping__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: percent(0.1f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -100,66 +113,398 @@ fn gap_row_gap_percentage_wrapping__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node5, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -171,6 +516,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -181,6 +527,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -191,6 +538,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -201,6 +549,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -211,6 +560,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -221,6 +571,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -231,6 +582,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -241,6 +593,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -251,6 +604,7 @@ fn gap_row_gap_percentage_wrapping__content_box() { let node8 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -263,6 +617,10 @@ fn gap_row_gap_percentage_wrapping__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: percent(0.1f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -274,64 +632,396 @@ fn gap_row_gap_percentage_wrapping__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node5, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs b/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs index 203ffd18c..84ac20da5 100644 --- a/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs +++ b/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs @@ -6,6 +6,7 @@ fn gap_row_gap_row_wrap_child_margins__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(2f32), bottom: length(2f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn gap_row_gap_row_wrap_child_margins__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -20,6 +22,7 @@ fn gap_row_gap_row_wrap_child_margins__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(15f32), bottom: length(15f32) }, ..Default::default() @@ -29,6 +32,10 @@ fn gap_row_gap_row_wrap_child_margins__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -43,30 +50,164 @@ fn gap_row_gap_row_wrap_child_margins__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 66f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 143f32, "y of node {:?}. Expected {}. Actual {}", node2, 143f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 143f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 143f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn gap_row_gap_row_wrap_child_margins__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(2f32), bottom: length(2f32) }, ..Default::default() @@ -86,6 +228,7 @@ fn gap_row_gap_row_wrap_child_margins__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -94,6 +237,7 @@ fn gap_row_gap_row_wrap_child_margins__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(15f32), bottom: length(15f32) }, ..Default::default() @@ -104,6 +248,10 @@ fn gap_row_gap_row_wrap_child_margins__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: zero(), height: length(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -118,28 +266,162 @@ fn gap_row_gap_row_wrap_child_margins__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 66f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 143f32, "y of node {:?}. Expected {}. Actual {}", node2, 143f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 143f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 143f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_cross_size_column.rs b/tests/generated/flex/intrinsic_sizing_cross_size_column.rs index 63bfff122..d23279aa3 100644 --- a/tests/generated/flex/intrinsic_sizing_cross_size_column.rs +++ b/tests/generated/flex/intrinsic_sizing_cross_size_column.rs @@ -6,7 +6,14 @@ fn intrinsic_sizing_cross_size_column__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,12 +21,47 @@ fn intrinsic_sizing_cross_size_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -33,6 +75,10 @@ fn intrinsic_sizing_cross_size_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), @@ -42,10 +88,45 @@ fn intrinsic_sizing_cross_size_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_column.rs b/tests/generated/flex/intrinsic_sizing_main_size_column.rs index 4fea3b7af..162bbbea9 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_column.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_column.rs @@ -6,7 +6,14 @@ fn intrinsic_sizing_main_size_column__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), ) .unwrap(); @@ -14,12 +21,47 @@ fn intrinsic_sizing_main_size_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -33,6 +75,10 @@ fn intrinsic_sizing_main_size_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), @@ -42,10 +88,45 @@ fn intrinsic_sizing_main_size_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs b/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs index 7003aad91..e32795e2a 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs @@ -6,13 +6,27 @@ fn intrinsic_sizing_main_size_column_nested__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -20,18 +34,86 @@ fn intrinsic_sizing_main_size_column_nested__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -45,6 +127,10 @@ fn intrinsic_sizing_main_size_column_nested__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), @@ -55,6 +141,10 @@ fn intrinsic_sizing_main_size_column_nested__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -64,16 +154,84 @@ fn intrinsic_sizing_main_size_column_nested__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs b/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs index 867df3aa3..42b8125a9 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs @@ -6,13 +6,27 @@ fn intrinsic_sizing_main_size_column_wrap__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), ) .unwrap(); @@ -21,6 +35,10 @@ fn intrinsic_sizing_main_size_column_wrap__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -30,24 +48,125 @@ fn intrinsic_sizing_main_size_column_wrap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +180,10 @@ fn intrinsic_sizing_main_size_column_wrap__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), @@ -71,6 +194,10 @@ fn intrinsic_sizing_main_size_column_wrap__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Vertical), @@ -82,6 +209,10 @@ fn intrinsic_sizing_main_size_column_wrap__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -91,22 +222,123 @@ fn intrinsic_sizing_main_size_column_wrap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_min_size.rs b/tests/generated/flex/intrinsic_sizing_main_size_min_size.rs index e7f26e8b4..079726338 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_min_size.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_min_size.rs @@ -7,6 +7,7 @@ fn intrinsic_sizing_main_size_min_size__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +26,10 @@ fn intrinsic_sizing_main_size_min_size__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), max_size: taffy::geometry::Size { @@ -47,6 +52,10 @@ fn intrinsic_sizing_main_size_min_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: taffy::style::Dimension::from_length(200f32), @@ -60,24 +69,131 @@ fn intrinsic_sizing_main_size_min_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +206,7 @@ fn intrinsic_sizing_main_size_min_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -109,6 +226,10 @@ fn intrinsic_sizing_main_size_min_size__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), max_size: taffy::geometry::Size { @@ -132,6 +253,10 @@ fn intrinsic_sizing_main_size_min_size__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: taffy::style::Dimension::from_length(200f32), @@ -145,22 +270,129 @@ fn intrinsic_sizing_main_size_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 70f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_row.rs b/tests/generated/flex/intrinsic_sizing_main_size_row.rs index 07712527b..a40d14b5d 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_row.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_row.rs @@ -6,7 +6,13 @@ fn intrinsic_sizing_main_size_row__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,12 +20,47 @@ fn intrinsic_sizing_main_size_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -30,7 +71,14 @@ fn intrinsic_sizing_main_size_row__content_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -38,10 +86,45 @@ fn intrinsic_sizing_main_size_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs b/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs index b277a6d65..35922ae07 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs @@ -6,27 +6,112 @@ fn intrinsic_sizing_main_size_row_nested__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -37,13 +122,27 @@ fn intrinsic_sizing_main_size_row_nested__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -51,16 +150,84 @@ fn intrinsic_sizing_main_size_row_nested__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs b/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs index b4a0f25a0..405567bde 100644 --- a/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs +++ b/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs @@ -6,19 +6,38 @@ fn intrinsic_sizing_main_size_row_wrap__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -26,24 +45,125 @@ fn intrinsic_sizing_main_size_row_wrap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,13 +174,27 @@ fn intrinsic_sizing_main_size_row_wrap__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -69,6 +203,10 @@ fn intrinsic_sizing_main_size_row_wrap__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -78,22 +216,123 @@ fn intrinsic_sizing_main_size_row_wrap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_center.rs b/tests/generated/flex/justify_content_column_center.rs index a6fdaeb46..9c63a5c39 100644 --- a/tests/generated/flex/justify_content_column_center.rs +++ b/tests/generated/flex/justify_content_column_center.rs @@ -6,18 +6,21 @@ fn justify_content_column_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_center__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node0, 35f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node0, 35f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_center_negative_space.rs b/tests/generated/flex/justify_content_column_center_negative_space.rs index 58283e5ad..1626472e2 100644 --- a/tests/generated/flex/justify_content_column_center_negative_space.rs +++ b/tests/generated/flex/justify_content_column_center_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_center_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_center_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_center_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_center_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_center_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_center_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node00, -25f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node02, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_center_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_center_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_center_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_center_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_center_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_center_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node00, -25f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node02, 15f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_center_negative_space_gap.rs b/tests/generated/flex/justify_content_column_center_negative_space_gap.rs index b549f129a..2ec118822 100644 --- a/tests/generated/flex/justify_content_column_center_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_center_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_center_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_center_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_center_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_center_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_center_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_center_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 35f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 35f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -35f32, "y of node {:?}. Expected {}. Actual {}", node00, -35f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node02, 25f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_center_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_center_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_center_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_center_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_center_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_center_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 35f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 35f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -35f32, "y of node {:?}. Expected {}. Actual {}", node00, -35f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node01, -5f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node02, 25f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_end.rs b/tests/generated/flex/justify_content_column_end.rs index 394c1f122..d7bc16d6d 100644 --- a/tests/generated/flex/justify_content_column_end.rs +++ b/tests/generated/flex/justify_content_column_end.rs @@ -6,18 +6,21 @@ fn justify_content_column_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_end__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_end_negative_space.rs b/tests/generated/flex/justify_content_column_end_negative_space.rs index 8bc66a046..3a8a306b9 100644 --- a/tests/generated/flex/justify_content_column_end_negative_space.rs +++ b/tests/generated/flex/justify_content_column_end_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_end_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_end_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_end_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_end_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_end_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_end_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node00, -50f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -30f32, "y of node {:?}. Expected {}. Actual {}", node01, -30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_end_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_end_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_end_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_end_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_end_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_end_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node00, -50f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -30f32, "y of node {:?}. Expected {}. Actual {}", node01, -30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_end_negative_space_gap.rs b/tests/generated/flex/justify_content_column_end_negative_space_gap.rs index b01408178..28e9c4f63 100644 --- a/tests/generated/flex/justify_content_column_end_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_end_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_end_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_end_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_end_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_end_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::End), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_end_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_end_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -70f32, "y of node {:?}. Expected {}. Actual {}", node00, -70f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, -40f32, "y of node {:?}. Expected {}. Actual {}", node01, -40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_end_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_end_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_end_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_end_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::End), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_end_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_end_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, -70f32, "y of node {:?}. Expected {}. Actual {}", node00, -70f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, -40f32, "y of node {:?}. Expected {}. Actual {}", node01, -40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_end_reverse.rs b/tests/generated/flex/justify_content_column_end_reverse.rs index aeba387f4..6aa59b3fe 100644 --- a/tests/generated/flex/justify_content_column_end_reverse.rs +++ b/tests/generated/flex/justify_content_column_end_reverse.rs @@ -6,18 +6,21 @@ fn justify_content_column_end_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_end_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_end_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_end_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_end_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_end_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_end_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_end_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_flex_end.rs b/tests/generated/flex/justify_content_column_flex_end.rs index e4a0ebd08..28d7708f1 100644 --- a/tests/generated/flex/justify_content_column_flex_end.rs +++ b/tests/generated/flex/justify_content_column_flex_end.rs @@ -6,18 +6,21 @@ fn justify_content_column_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_flex_end__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_flex_end_reverse.rs b/tests/generated/flex/justify_content_column_flex_end_reverse.rs index d1012cbf9..f880a5a80 100644 --- a/tests/generated/flex/justify_content_column_flex_end_reverse.rs +++ b/tests/generated/flex/justify_content_column_flex_end_reverse.rs @@ -6,18 +6,21 @@ fn justify_content_column_flex_end_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_flex_end_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_flex_end_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_flex_end_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_flex_end_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_flex_end_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_flex_end_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_flex_end_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_flex_start.rs b/tests/generated/flex/justify_content_column_flex_start.rs index 36ce0b2c7..dbec8620a 100644 --- a/tests/generated/flex/justify_content_column_flex_start.rs +++ b/tests/generated/flex/justify_content_column_flex_start.rs @@ -6,18 +6,21 @@ fn justify_content_column_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_flex_start__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_flex_start_reverse.rs b/tests/generated/flex/justify_content_column_flex_start_reverse.rs index 510ec63ed..87d3e3414 100644 --- a/tests/generated/flex/justify_content_column_flex_start_reverse.rs +++ b/tests/generated/flex/justify_content_column_flex_start_reverse.rs @@ -6,18 +6,21 @@ fn justify_content_column_flex_start_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_flex_start_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_flex_start_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node2, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_flex_start_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_flex_start_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_flex_start_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_flex_start_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_flex_start_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node2, 70f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_max_height_and_margin.rs b/tests/generated/flex/justify_content_column_max_height_and_margin.rs index 46f96272b..ce3ab299d 100644 --- a/tests/generated/flex/justify_content_column_max_height_and_margin.rs +++ b/tests/generated/flex/justify_content_column_max_height_and_margin.rs @@ -6,6 +6,7 @@ fn justify_content_column_max_height_and_margin__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn justify_content_column_max_height_and_margin__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, @@ -26,29 +31,147 @@ fn justify_content_column_max_height_and_margin__border_box() { &[node00], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 180f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node00, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +183,7 @@ fn justify_content_column_max_height_and_margin__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -72,6 +196,10 @@ fn justify_content_column_max_height_and_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(80f32) }, @@ -83,7 +211,14 @@ fn justify_content_column_max_height_and_margin__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -91,22 +226,129 @@ fn justify_content_column_max_height_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 180f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node00, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_min_height_and_margin.rs b/tests/generated/flex/justify_content_column_min_height_and_margin.rs index 0baf3e3b5..c4e92c660 100644 --- a/tests/generated/flex/justify_content_column_min_height_and_margin.rs +++ b/tests/generated/flex/justify_content_column_min_height_and_margin.rs @@ -6,6 +6,7 @@ fn justify_content_column_min_height_and_margin__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn justify_content_column_min_height_and_margin__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(100f32), bottom: zero() }, @@ -25,29 +30,147 @@ fn justify_content_column_min_height_and_margin__border_box() { &[node00], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 150f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node00, 15f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +182,7 @@ fn justify_content_column_min_height_and_margin__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -71,6 +195,10 @@ fn justify_content_column_min_height_and_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(100f32), bottom: zero() }, @@ -81,7 +209,14 @@ fn justify_content_column_min_height_and_margin__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -89,22 +224,129 @@ fn justify_content_column_min_height_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 150f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node00, 15f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs b/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs index 519a706b8..909e7ea74 100644 --- a/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs +++ b/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs @@ -6,6 +6,7 @@ fn justify_content_column_min_height_and_margin_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn justify_content_column_min_height_and_margin_bottom__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -29,18 +34,86 @@ fn justify_content_column_min_height_and_margin_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn justify_content_column_min_height_and_margin_bottom__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -65,6 +139,10 @@ fn justify_content_column_min_height_and_margin_bottom__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -76,16 +154,84 @@ fn justify_content_column_min_height_and_margin_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs b/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs index 1f1c79b72..21380d1ea 100644 --- a/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs +++ b/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs @@ -6,6 +6,7 @@ fn justify_content_column_min_height_and_margin_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn justify_content_column_min_height_and_margin_top__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -29,18 +34,86 @@ fn justify_content_column_min_height_and_margin_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn justify_content_column_min_height_and_margin_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -65,6 +139,10 @@ fn justify_content_column_min_height_and_margin_top__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -76,16 +154,84 @@ fn justify_content_column_min_height_and_margin_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_around.rs b/tests/generated/flex/justify_content_column_space_around.rs index fbb659051..646788d47 100644 --- a/tests/generated/flex/justify_content_column_space_around.rs +++ b/tests/generated/flex/justify_content_column_space_around.rs @@ -6,18 +6,21 @@ fn justify_content_column_space_around__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_space_around__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node2, 78f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_space_around__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_space_around__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_space_around__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_space_around__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node2, 78f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 78f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_around_negative_space.rs b/tests/generated/flex/justify_content_column_space_around_negative_space.rs index 8005047cb..4a4d105ed 100644 --- a/tests/generated/flex/justify_content_column_space_around_negative_space.rs +++ b/tests/generated/flex/justify_content_column_space_around_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_around_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_around_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_around_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_around_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_space_around_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_space_around_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_space_around_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_space_around_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_space_around_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_space_around_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_space_around_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_space_around_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs b/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs index 0ebc2579a..6079ab9d4 100644 --- a/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_space_around_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_space_around_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_between.rs b/tests/generated/flex/justify_content_column_space_between.rs index 3c4e638a0..25a99596d 100644 --- a/tests/generated/flex/justify_content_column_space_between.rs +++ b/tests/generated/flex/justify_content_column_space_between.rs @@ -6,18 +6,21 @@ fn justify_content_column_space_between__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_space_between__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_space_between__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_space_between__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_space_between__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_space_between__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_between_negative_space.rs b/tests/generated/flex/justify_content_column_space_between_negative_space.rs index 81b462b2f..56024b596 100644 --- a/tests/generated/flex/justify_content_column_space_between_negative_space.rs +++ b/tests/generated/flex/justify_content_column_space_between_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_between_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_between_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_between_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_between_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_space_between_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_space_between_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_space_between_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_space_between_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_space_between_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_space_between_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_space_between_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_space_between_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs b/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs index ea01c2fce..c616f5aad 100644 --- a/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_space_between_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_space_between_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_evenly.rs b/tests/generated/flex/justify_content_column_space_evenly.rs index 788d95bb7..4cf56db59 100644 --- a/tests/generated/flex/justify_content_column_space_evenly.rs +++ b/tests/generated/flex/justify_content_column_space_evenly.rs @@ -6,18 +6,21 @@ fn justify_content_column_space_evenly__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_space_evenly__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_space_evenly__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node2, 73f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_space_evenly__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_space_evenly__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_space_evenly__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_space_evenly__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_space_evenly__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node2, 73f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 73f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 73f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs b/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs index 82e5ad725..fa82daed4 100644 --- a/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs +++ b/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_evenly_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_evenly_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_evenly_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_evenly_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_space_evenly_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_space_evenly_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_space_evenly_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_space_evenly_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_space_evenly_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_space_evenly_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_space_evenly_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_space_evenly_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs b/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs index e4794e5ae..1e82932ca 100644 --- a/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_space_evenly_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_space_evenly_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_start.rs b/tests/generated/flex/justify_content_column_start.rs index 7910190d0..940c8d906 100644 --- a/tests/generated/flex/justify_content_column_start.rs +++ b/tests/generated/flex/justify_content_column_start.rs @@ -6,18 +6,21 @@ fn justify_content_column_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_start__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_start_negative_space.rs b/tests/generated/flex/justify_content_column_start_negative_space.rs index b6fb16916..a9e365311 100644 --- a/tests/generated/flex/justify_content_column_start_negative_space.rs +++ b/tests/generated/flex/justify_content_column_start_negative_space.rs @@ -6,6 +6,7 @@ fn justify_content_column_start_negative_space__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_start_negative_space__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_start_negative_space__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_start_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -52,6 +59,10 @@ fn justify_content_column_start_negative_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -71,36 +82,221 @@ fn justify_content_column_start_negative_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +308,7 @@ fn justify_content_column_start_negative_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -123,6 +320,7 @@ fn justify_content_column_start_negative_space__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -134,6 +332,7 @@ fn justify_content_column_start_negative_space__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -148,6 +347,10 @@ fn justify_content_column_start_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, @@ -162,6 +365,10 @@ fn justify_content_column_start_negative_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -181,34 +388,219 @@ fn justify_content_column_start_negative_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_start_negative_space_gap.rs b/tests/generated/flex/justify_content_column_start_negative_space_gap.rs index f7e0206e8..ecf153806 100644 --- a/tests/generated/flex/justify_content_column_start_negative_space_gap.rs +++ b/tests/generated/flex/justify_content_column_start_negative_space_gap.rs @@ -6,6 +6,7 @@ fn justify_content_column_start_negative_space_gap__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -16,6 +17,7 @@ fn justify_content_column_start_negative_space_gap__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -26,6 +28,7 @@ fn justify_content_column_start_negative_space_gap__border_box() { .unwrap(); let node02 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -39,6 +42,10 @@ fn justify_content_column_start_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Start), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -53,6 +60,10 @@ fn justify_content_column_start_negative_space_gap__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -72,36 +83,221 @@ fn justify_content_column_start_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,6 +309,7 @@ fn justify_content_column_start_negative_space_gap__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -124,6 +321,7 @@ fn justify_content_column_start_negative_space_gap__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -135,6 +333,7 @@ fn justify_content_column_start_negative_space_gap__content_box() { let node02 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.8f32), @@ -149,6 +348,10 @@ fn justify_content_column_start_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Start), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -164,6 +367,10 @@ fn justify_content_column_start_negative_space_gap__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: taffy::style::Dimension::from_length(320f32), @@ -183,34 +390,219 @@ fn justify_content_column_start_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 440f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 70f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node01, 30f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node02, 60f32, location.y); + if layout.size.width != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 256f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 32f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_column_start_reverse.rs b/tests/generated/flex/justify_content_column_start_reverse.rs index 5c7ecd460..f98a70d84 100644 --- a/tests/generated/flex/justify_content_column_start_reverse.rs +++ b/tests/generated/flex/justify_content_column_start_reverse.rs @@ -6,18 +6,21 @@ fn justify_content_column_start_reverse__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -26,6 +29,10 @@ fn justify_content_column_start_reverse__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -40,30 +47,164 @@ fn justify_content_column_start_reverse__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +216,7 @@ fn justify_content_column_start_reverse__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -82,6 +224,7 @@ fn justify_content_column_start_reverse__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -89,6 +232,7 @@ fn justify_content_column_start_reverse__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -98,6 +242,10 @@ fn justify_content_column_start_reverse__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::ColumnReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -112,28 +260,162 @@ fn justify_content_column_start_reverse__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_min_max.rs b/tests/generated/flex/justify_content_min_max.rs index fdb43dc69..bcef03e9b 100644 --- a/tests/generated/flex/justify_content_min_max.rs +++ b/tests/generated/flex/justify_content_min_max.rs @@ -6,6 +6,7 @@ fn justify_content_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,10 @@ fn justify_content_min_max__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -30,18 +35,86 @@ fn justify_content_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn justify_content_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(60f32), @@ -65,6 +139,10 @@ fn justify_content_min_max__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, @@ -78,16 +156,84 @@ fn justify_content_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs index 053a1b731..840f09f5c 100644 --- a/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs +++ b/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -6,6 +6,7 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__borde let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), @@ -17,6 +18,10 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__borde let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, @@ -33,7 +38,14 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__borde .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_content: Some(taffy::style::AlignContent::Stretch), + ..Default::default() + }, &[node00], ) .unwrap(); @@ -41,6 +53,10 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__borde .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1000f32), @@ -55,30 +71,200 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__borde println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node, 1000f32, size.width); - assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1000f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1000f32, layout.size.width); + } + if layout.size.height != 1584f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 1584f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node0, 1000f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1000f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1000f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node00, 500f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node000, 300f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node000, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 300f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(location.x), + 100f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +276,7 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__conte let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), @@ -102,6 +289,10 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__conte .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, @@ -120,6 +311,10 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__conte .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -131,6 +326,10 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__conte taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1000f32), @@ -145,28 +344,198 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent__conte println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node, 1000f32, size.width); - assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1000f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1000f32, layout.size.width); + } + if layout.size.height != 1584f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 1584f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node0, 1000f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1000f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1000f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node000, 300f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node000, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 300f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(location.x), + 150f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs index 5fbfee82e..534899f9f 100644 --- a/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs +++ b/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -6,6 +6,7 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__border_ let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(199f32), @@ -17,6 +18,10 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__border_ let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, @@ -33,7 +38,14 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__border_ .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + align_content: Some(taffy::style::AlignContent::Stretch), + ..Default::default() + }, &[node00], ) .unwrap(); @@ -41,6 +53,10 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__border_ .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1080f32), @@ -55,30 +71,200 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__border_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); - assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 1584f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 1584f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node00, 400f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 199f32, "width of node {:?}. Expected {}. Actual {}", node000, 199f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 101f32, "x of node {:?}. Expected {}. Actual {}", node000, 101f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 199f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 199f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 101f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(location.x), + 101f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +276,7 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__content let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(199f32), @@ -102,6 +289,10 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__content .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, @@ -120,6 +311,10 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__content .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, @@ -131,6 +326,10 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__content taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1080f32), @@ -145,28 +344,198 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent__content println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); - assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 1584f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 1584f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 1080f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 1080f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 199f32, "width of node {:?}. Expected {}. Actual {}", node000, 199f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); - assert_eq!(location.x, 201f32, "x of node {:?}. Expected {}. Actual {}", node000, 201f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 199f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.width), + 199f32, + layout.size.width + ); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 201f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(location.x), + 201f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_overflow_min_max.rs b/tests/generated/flex/justify_content_overflow_min_max.rs index 233e07fb4..6bf4e4af2 100644 --- a/tests/generated/flex/justify_content_overflow_min_max.rs +++ b/tests/generated/flex/justify_content_overflow_min_max.rs @@ -6,6 +6,7 @@ fn justify_content_overflow_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -16,6 +17,7 @@ fn justify_content_overflow_min_max__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -26,6 +28,7 @@ fn justify_content_overflow_min_max__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -38,6 +41,10 @@ fn justify_content_overflow_min_max__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(110f32) }, @@ -50,30 +57,164 @@ fn justify_content_overflow_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 110f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node0, -20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -85,6 +226,7 @@ fn justify_content_overflow_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -96,6 +238,7 @@ fn justify_content_overflow_min_max__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -107,6 +250,7 @@ fn justify_content_overflow_min_max__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -120,6 +264,10 @@ fn justify_content_overflow_min_max__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(110f32) }, @@ -132,28 +280,162 @@ fn justify_content_overflow_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 110f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node0, -20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_center.rs b/tests/generated/flex/justify_content_row_center.rs index 649e3f523..9660f3d66 100644 --- a/tests/generated/flex/justify_content_row_center.rs +++ b/tests/generated/flex/justify_content_row_center.rs @@ -6,18 +6,21 @@ fn justify_content_row_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn justify_content_row_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node0, 35f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn justify_content_row_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn justify_content_row_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn justify_content_row_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn justify_content_row_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn justify_content_row_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node0, 35f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_flex_end.rs b/tests/generated/flex/justify_content_row_flex_end.rs index 175ad1575..eb21d7017 100644 --- a/tests/generated/flex/justify_content_row_flex_end.rs +++ b/tests/generated/flex/justify_content_row_flex_end.rs @@ -6,18 +6,21 @@ fn justify_content_row_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_flex_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn justify_content_row_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn justify_content_row_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn justify_content_row_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn justify_content_row_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn justify_content_row_flex_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn justify_content_row_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_flex_start.rs b/tests/generated/flex/justify_content_row_flex_start.rs index 7ab55be57..af42a673d 100644 --- a/tests/generated/flex/justify_content_row_flex_start.rs +++ b/tests/generated/flex/justify_content_row_flex_start.rs @@ -6,18 +6,21 @@ fn justify_content_row_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_flex_start__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn justify_content_row_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn justify_content_row_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn justify_content_row_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn justify_content_row_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn justify_content_row_flex_start__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn justify_content_row_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_max_width_and_margin.rs b/tests/generated/flex/justify_content_row_max_width_and_margin.rs index 0ca8300a1..0ad3cb02b 100644 --- a/tests/generated/flex/justify_content_row_max_width_and_margin.rs +++ b/tests/generated/flex/justify_content_row_max_width_and_margin.rs @@ -6,6 +6,7 @@ fn justify_content_row_max_width_and_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn justify_content_row_max_width_and_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, @@ -29,18 +34,86 @@ fn justify_content_row_max_width_and_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn justify_content_row_max_width_and_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -64,6 +138,10 @@ fn justify_content_row_max_width_and_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, @@ -76,16 +154,84 @@ fn justify_content_row_max_width_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_min_width_and_margin.rs b/tests/generated/flex/justify_content_row_min_width_and_margin.rs index 2bf6f41f6..d697d7764 100644 --- a/tests/generated/flex/justify_content_row_min_width_and_margin.rs +++ b/tests/generated/flex/justify_content_row_min_width_and_margin.rs @@ -6,6 +6,7 @@ fn justify_content_row_min_width_and_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn justify_content_row_min_width_and_margin__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -28,18 +33,86 @@ fn justify_content_row_min_width_and_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn justify_content_row_min_width_and_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -63,6 +137,10 @@ fn justify_content_row_min_width_and_margin__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -74,16 +152,84 @@ fn justify_content_row_min_width_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_space_around.rs b/tests/generated/flex/justify_content_row_space_around.rs index 3cf9ae337..af8b9dd10 100644 --- a/tests/generated/flex/justify_content_row_space_around.rs +++ b/tests/generated/flex/justify_content_row_space_around.rs @@ -6,18 +6,21 @@ fn justify_content_row_space_around__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_space_around__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn justify_content_row_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node0, 12f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 78f32, "x of node {:?}. Expected {}. Actual {}", node2, 78f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 78f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn justify_content_row_space_around__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn justify_content_row_space_around__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn justify_content_row_space_around__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn justify_content_row_space_around__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn justify_content_row_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node0, 12f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 78f32, "x of node {:?}. Expected {}. Actual {}", node2, 78f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 78f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 78f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_space_between.rs b/tests/generated/flex/justify_content_row_space_between.rs index 44f01f902..314c6a1c7 100644 --- a/tests/generated/flex/justify_content_row_space_between.rs +++ b/tests/generated/flex/justify_content_row_space_between.rs @@ -6,18 +6,21 @@ fn justify_content_row_space_between__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_space_between__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,182 @@ fn justify_content_row_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +233,7 @@ fn justify_content_row_space_between__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -81,6 +241,7 @@ fn justify_content_row_space_between__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -88,6 +249,7 @@ fn justify_content_row_space_between__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) @@ -96,6 +258,10 @@ fn justify_content_row_space_between__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +276,180 @@ fn justify_content_row_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/justify_content_row_space_evenly.rs b/tests/generated/flex/justify_content_row_space_evenly.rs index e9e5d5f64..c6ab68741 100644 --- a/tests/generated/flex/justify_content_row_space_evenly.rs +++ b/tests/generated/flex/justify_content_row_space_evenly.rs @@ -6,18 +6,21 @@ fn justify_content_row_space_evenly__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -25,6 +28,10 @@ fn justify_content_row_space_evenly__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -39,30 +46,164 @@ fn justify_content_row_space_evenly__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +215,7 @@ fn justify_content_row_space_evenly__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -81,6 +223,7 @@ fn justify_content_row_space_evenly__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -88,6 +231,7 @@ fn justify_content_row_space_evenly__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -96,6 +240,10 @@ fn justify_content_row_space_evenly__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,28 +258,162 @@ fn justify_content_row_space_evenly__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_and_flex_column.rs b/tests/generated/flex/margin_and_flex_column.rs index 6dcfefd55..80521fb4d 100644 --- a/tests/generated/flex/margin_and_flex_column.rs +++ b/tests/generated/flex/margin_and_flex_column.rs @@ -6,6 +6,7 @@ fn margin_and_flex_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,10 @@ fn margin_and_flex_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn margin_and_flex_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn margin_and_flex_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -61,6 +135,10 @@ fn margin_and_flex_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn margin_and_flex_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_and_flex_row.rs b/tests/generated/flex/margin_and_flex_row.rs index e4f7d56e8..f610a8e73 100644 --- a/tests/generated/flex/margin_and_flex_row.rs +++ b/tests/generated/flex/margin_and_flex_row.rs @@ -6,6 +6,7 @@ fn margin_and_flex_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(10f32), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -14,6 +15,10 @@ fn margin_and_flex_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,92 @@ fn margin_and_flex_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +129,7 @@ fn margin_and_flex_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(10f32), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -59,6 +139,10 @@ fn margin_and_flex_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +156,90 @@ fn margin_and_flex_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_and_stretch_column.rs b/tests/generated/flex/margin_and_stretch_column.rs index 1ec4478fd..2e808aafb 100644 --- a/tests/generated/flex/margin_and_stretch_column.rs +++ b/tests/generated/flex/margin_and_stretch_column.rs @@ -6,6 +6,7 @@ fn margin_and_stretch_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(10f32), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -15,6 +16,10 @@ fn margin_and_stretch_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,92 @@ fn margin_and_stretch_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +130,7 @@ fn margin_and_stretch_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: length(10f32), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -61,6 +141,10 @@ fn margin_and_stretch_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +158,90 @@ fn margin_and_stretch_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_and_stretch_row.rs b/tests/generated/flex/margin_and_stretch_row.rs index 84b70771c..89344c79f 100644 --- a/tests/generated/flex/margin_and_stretch_row.rs +++ b/tests/generated/flex/margin_and_stretch_row.rs @@ -6,6 +6,7 @@ fn margin_and_stretch_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -14,6 +15,10 @@ fn margin_and_stretch_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,86 @@ fn margin_and_stretch_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +123,7 @@ fn margin_and_stretch_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: length(10f32) }, ..Default::default() @@ -59,6 +133,10 @@ fn margin_and_stretch_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +150,84 @@ fn margin_and_stretch_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_bottom.rs b/tests/generated/flex/margin_auto_bottom.rs index 945829909..44aac57e2 100644 --- a/tests/generated/flex/margin_auto_bottom.rs +++ b/tests/generated/flex/margin_auto_bottom.rs @@ -6,6 +6,7 @@ fn margin_auto_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_bottom__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_bottom__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_bottom__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_bottom__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_bottom__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_bottom_and_top.rs b/tests/generated/flex/margin_auto_bottom_and_top.rs index b459cc9b6..9a015216d 100644 --- a/tests/generated/flex/margin_auto_bottom_and_top.rs +++ b/tests/generated/flex/margin_auto_bottom_and_top.rs @@ -6,6 +6,7 @@ fn margin_auto_bottom_and_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_bottom_and_top__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_bottom_and_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_bottom_and_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_bottom_and_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_bottom_and_top__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_bottom_and_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_bottom_and_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs b/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs index 2f2f75357..88d93dd9c 100644 --- a/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs +++ b/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs @@ -6,6 +6,7 @@ fn margin_auto_bottom_and_top_justify_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_bottom_and_top_justify_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_bottom_and_top_justify_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_bottom_and_top_justify_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_bottom_and_top_justify_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_bottom_and_top_justify_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_bottom_and_top_justify_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_bottom_and_top_justify_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left.rs b/tests/generated/flex/margin_auto_left.rs index f9331dbcc..2b8a70976 100644 --- a/tests/generated/flex/margin_auto_left.rs +++ b/tests/generated/flex/margin_auto_left.rs @@ -6,6 +6,7 @@ fn margin_auto_left__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_left__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_left__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_left__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_left__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_left__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_and_right.rs b/tests/generated/flex/margin_auto_left_and_right.rs index ceb13b5ae..b129928e1 100644 --- a/tests/generated/flex/margin_auto_left_and_right.rs +++ b/tests/generated/flex/margin_auto_left_and_right.rs @@ -6,6 +6,7 @@ fn margin_auto_left_and_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_left_and_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_left_and_right__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -44,24 +50,125 @@ fn margin_auto_left_and_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +180,7 @@ fn margin_auto_left_and_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -89,6 +197,7 @@ fn margin_auto_left_and_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -100,6 +209,10 @@ fn margin_auto_left_and_right__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -113,22 +226,123 @@ fn margin_auto_left_and_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_and_right_column.rs b/tests/generated/flex/margin_auto_left_and_right_column.rs index 57692212d..b1aa589e9 100644 --- a/tests/generated/flex/margin_auto_left_and_right_column.rs +++ b/tests/generated/flex/margin_auto_left_and_right_column.rs @@ -6,6 +6,7 @@ fn margin_auto_left_and_right_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_left_and_right_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_left_and_right_column__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_left_and_right_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_left_and_right_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_left_and_right_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_left_and_right_column__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_left_and_right_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs b/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs index 526f1b6d7..92597a071 100644 --- a/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs +++ b/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs @@ -6,6 +6,7 @@ fn margin_auto_left_and_right_column_and_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_left_and_right_column_and_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_left_and_right_column_and_center__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_left_and_right_column_and_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_left_and_right_column_and_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_left_and_right_column_and_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_left_and_right_column_and_center__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_left_and_right_column_and_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_and_right_stretch.rs b/tests/generated/flex/margin_auto_left_and_right_stretch.rs index 452add0f5..968a9d5dd 100644 --- a/tests/generated/flex/margin_auto_left_and_right_stretch.rs +++ b/tests/generated/flex/margin_auto_left_and_right_stretch.rs @@ -6,6 +6,7 @@ fn margin_auto_left_and_right_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_left_and_right_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_left_and_right_stretch__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_left_and_right_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_left_and_right_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_left_and_right_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_left_and_right_stretch__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_left_and_right_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs b/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs index 469fcfb22..40bd33a78 100644 --- a/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs +++ b/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn margin_auto_left_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -22,6 +23,10 @@ fn margin_auto_left_child_bigger_than_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn margin_auto_left_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn margin_auto_left_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -76,6 +150,10 @@ fn margin_auto_left_child_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn margin_auto_left_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs index 15991e421..aa1592acd 100644 --- a/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -22,6 +23,10 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 42f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -76,6 +150,10 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn margin_auto_left_fix_right_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 42f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs index 2111ba453..64a5ddbda 100644 --- a/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs +++ b/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn margin_auto_left_right_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -22,6 +23,10 @@ fn margin_auto_left_right_child_bigger_than_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn margin_auto_left_right_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn margin_auto_left_right_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -76,6 +150,10 @@ fn margin_auto_left_right_child_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn margin_auto_left_right_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_left_stretching_child.rs b/tests/generated/flex/margin_auto_left_stretching_child.rs index c0199a749..cb9a1bdbf 100644 --- a/tests/generated/flex/margin_auto_left_stretching_child.rs +++ b/tests/generated/flex/margin_auto_left_stretching_child.rs @@ -6,6 +6,7 @@ fn margin_auto_left_stretching_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -20,6 +21,7 @@ fn margin_auto_left_stretching_child__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -30,6 +32,10 @@ fn margin_auto_left_stretching_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -44,24 +50,125 @@ fn margin_auto_left_stretching_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +180,7 @@ fn margin_auto_left_stretching_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -88,6 +196,7 @@ fn margin_auto_left_stretching_child__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -99,6 +208,10 @@ fn margin_auto_left_stretching_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -113,22 +226,123 @@ fn margin_auto_left_stretching_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_multiple_children_column.rs b/tests/generated/flex/margin_auto_multiple_children_column.rs index 46f112abe..3edb81d2a 100644 --- a/tests/generated/flex/margin_auto_multiple_children_column.rs +++ b/tests/generated/flex/margin_auto_multiple_children_column.rs @@ -6,6 +6,7 @@ fn margin_auto_multiple_children_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_multiple_children_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -36,6 +38,7 @@ fn margin_auto_multiple_children_column__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -47,6 +50,10 @@ fn margin_auto_multiple_children_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -61,30 +68,164 @@ fn margin_auto_multiple_children_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node2, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -96,6 +237,7 @@ fn margin_auto_multiple_children_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -112,6 +254,7 @@ fn margin_auto_multiple_children_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -128,6 +271,7 @@ fn margin_auto_multiple_children_column__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -140,6 +284,10 @@ fn margin_auto_multiple_children_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -154,28 +302,162 @@ fn margin_auto_multiple_children_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node2, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_multiple_children_row.rs b/tests/generated/flex/margin_auto_multiple_children_row.rs index c40b70ac8..02caa4d77 100644 --- a/tests/generated/flex/margin_auto_multiple_children_row.rs +++ b/tests/generated/flex/margin_auto_multiple_children_row.rs @@ -6,6 +6,7 @@ fn margin_auto_multiple_children_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_multiple_children_row__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -36,6 +38,7 @@ fn margin_auto_multiple_children_row__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -46,6 +49,10 @@ fn margin_auto_multiple_children_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -60,30 +67,164 @@ fn margin_auto_multiple_children_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node2, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node2, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +236,7 @@ fn margin_auto_multiple_children_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -111,6 +253,7 @@ fn margin_auto_multiple_children_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -127,6 +270,7 @@ fn margin_auto_multiple_children_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -138,6 +282,10 @@ fn margin_auto_multiple_children_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -152,28 +300,162 @@ fn margin_auto_multiple_children_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 75f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node2, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node2, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_right.rs b/tests/generated/flex/margin_auto_right.rs index 5ef8008c0..8a0e1cc08 100644 --- a/tests/generated/flex/margin_auto_right.rs +++ b/tests/generated/flex/margin_auto_right.rs @@ -6,6 +6,7 @@ fn margin_auto_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_right__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_right__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_right__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_right__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_top.rs b/tests/generated/flex/margin_auto_top.rs index 8205e394d..71d4ad0eb 100644 --- a/tests/generated/flex/margin_auto_top.rs +++ b/tests/generated/flex/margin_auto_top.rs @@ -6,6 +6,7 @@ fn margin_auto_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_top__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -31,6 +33,10 @@ fn margin_auto_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -45,24 +51,125 @@ fn margin_auto_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +181,7 @@ fn margin_auto_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -90,6 +198,7 @@ fn margin_auto_top__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -101,6 +210,10 @@ fn margin_auto_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -115,22 +228,123 @@ fn margin_auto_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs b/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs index 1e35061fd..643c074ac 100644 --- a/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs +++ b/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs @@ -6,6 +6,7 @@ fn margin_auto_top_and_bottom_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -21,6 +22,7 @@ fn margin_auto_top_and_bottom_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +34,10 @@ fn margin_auto_top_and_bottom_stretch__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,24 +52,125 @@ fn margin_auto_top_and_bottom_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node1, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn margin_auto_top_and_bottom_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -91,6 +199,7 @@ fn margin_auto_top_and_bottom_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +212,10 @@ fn margin_auto_top_and_bottom_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -117,22 +230,123 @@ fn margin_auto_top_and_bottom_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node1, 150f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_auto_top_stretching_child.rs b/tests/generated/flex/margin_auto_top_stretching_child.rs index 5074f0577..37520d7cf 100644 --- a/tests/generated/flex/margin_auto_top_stretching_child.rs +++ b/tests/generated/flex/margin_auto_top_stretching_child.rs @@ -6,6 +6,7 @@ fn margin_auto_top_stretching_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -20,6 +21,7 @@ fn margin_auto_top_stretching_child__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -30,6 +32,10 @@ fn margin_auto_top_stretching_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -44,24 +50,125 @@ fn margin_auto_top_stretching_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node0, 200f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -73,6 +180,7 @@ fn margin_auto_top_stretching_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -88,6 +196,7 @@ fn margin_auto_top_stretching_child__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -99,6 +208,10 @@ fn margin_auto_top_stretching_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -113,22 +226,123 @@ fn margin_auto_top_stretching_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node0, 200f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 150f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_bottom.rs b/tests/generated/flex/margin_bottom.rs index d97367f8c..63bea8df4 100644 --- a/tests/generated/flex/margin_bottom.rs +++ b/tests/generated/flex/margin_bottom.rs @@ -6,6 +6,7 @@ fn margin_bottom__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -15,6 +16,10 @@ fn margin_bottom__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,86 @@ fn margin_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +125,7 @@ fn margin_bottom__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -62,6 +136,10 @@ fn margin_bottom__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -76,16 +154,84 @@ fn margin_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs b/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs index 1bf409d36..035f46960 100644 --- a/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs +++ b/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -6,6 +6,7 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -22,6 +23,10 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -36,18 +41,86 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 42f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(72f32), height: taffy::style::Dimension::from_length(72f32), @@ -76,6 +150,10 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), @@ -90,16 +168,84 @@ fn margin_fix_left_auto_right_child_bigger_than_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); - assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 42f32, layout.size.width); + } + if layout.size.height != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 72f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_left.rs b/tests/generated/flex/margin_left.rs index fadc4dbc8..b537e7f99 100644 --- a/tests/generated/flex/margin_left.rs +++ b/tests/generated/flex/margin_left.rs @@ -6,6 +6,7 @@ fn margin_left__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), right: zero(), top: zero(), bottom: zero() }, ..Default::default() @@ -14,6 +15,10 @@ fn margin_left__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,92 @@ fn margin_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +129,7 @@ fn margin_left__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: length(10f32), right: zero(), top: zero(), bottom: zero() }, ..Default::default() @@ -59,6 +139,10 @@ fn margin_left__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +156,90 @@ fn margin_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_right.rs b/tests/generated/flex/margin_right.rs index 8b2bdbaa3..cb3361daf 100644 --- a/tests/generated/flex/margin_right.rs +++ b/tests/generated/flex/margin_right.rs @@ -6,6 +6,7 @@ fn margin_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -14,6 +15,10 @@ fn margin_right__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,92 @@ fn margin_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +130,7 @@ fn margin_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -60,6 +140,10 @@ fn margin_right__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -74,16 +158,90 @@ fn margin_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_should_not_be_part_of_max_height.rs b/tests/generated/flex/margin_should_not_be_part_of_max_height.rs index 7952bcaaf..848e6fa54 100644 --- a/tests/generated/flex/margin_should_not_be_part_of_max_height.rs +++ b/tests/generated/flex/margin_should_not_be_part_of_max_height.rs @@ -6,6 +6,7 @@ fn margin_should_not_be_part_of_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -18,6 +19,10 @@ fn margin_should_not_be_part_of_max_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(250f32), height: taffy::style::Dimension::from_length(250f32), @@ -31,18 +36,92 @@ fn margin_should_not_be_part_of_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 250f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +133,7 @@ fn margin_should_not_be_part_of_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -67,6 +147,10 @@ fn margin_should_not_be_part_of_max_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(250f32), height: taffy::style::Dimension::from_length(250f32), @@ -80,16 +164,90 @@ fn margin_should_not_be_part_of_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 250f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_should_not_be_part_of_max_width.rs b/tests/generated/flex/margin_should_not_be_part_of_max_width.rs index 7a4f02a56..8717e189c 100644 --- a/tests/generated/flex/margin_should_not_be_part_of_max_width.rs +++ b/tests/generated/flex/margin_should_not_be_part_of_max_width.rs @@ -6,6 +6,7 @@ fn margin_should_not_be_part_of_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -18,6 +19,10 @@ fn margin_should_not_be_part_of_max_width__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(250f32), height: taffy::style::Dimension::from_length(250f32), @@ -31,18 +36,92 @@ fn margin_should_not_be_part_of_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 250f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +133,7 @@ fn margin_should_not_be_part_of_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -67,6 +147,10 @@ fn margin_should_not_be_part_of_max_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(250f32), height: taffy::style::Dimension::from_length(250f32), @@ -80,16 +164,90 @@ fn margin_should_not_be_part_of_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 250f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 250f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_top.rs b/tests/generated/flex/margin_top.rs index 7e67e47f8..fc3fdf24e 100644 --- a/tests/generated/flex/margin_top.rs +++ b/tests/generated/flex/margin_top.rs @@ -6,6 +6,7 @@ fn margin_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -15,6 +16,10 @@ fn margin_top__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn margin_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn margin_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() @@ -61,6 +135,10 @@ fn margin_top__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn margin_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_with_sibling_column.rs b/tests/generated/flex/margin_with_sibling_column.rs index d2a1b59ca..d4e223ce2 100644 --- a/tests/generated/flex/margin_with_sibling_column.rs +++ b/tests/generated/flex/margin_with_sibling_column.rs @@ -6,16 +6,27 @@ fn margin_with_sibling_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,24 +40,125 @@ fn margin_with_sibling_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node0, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node1, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node1, 55f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +170,7 @@ fn margin_with_sibling_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(10f32) }, ..Default::default() @@ -66,6 +179,7 @@ fn margin_with_sibling_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -75,6 +189,10 @@ fn margin_with_sibling_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,22 +206,123 @@ fn margin_with_sibling_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node0, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node1, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node1, 55f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/margin_with_sibling_row.rs b/tests/generated/flex/margin_with_sibling_row.rs index a221f9b3e..02c2229c7 100644 --- a/tests/generated/flex/margin_with_sibling_row.rs +++ b/tests/generated/flex/margin_with_sibling_row.rs @@ -6,15 +6,26 @@ fn margin_with_sibling_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,24 +39,137 @@ fn margin_with_sibling_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node0, 45f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node1, 45f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node1, 55f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +181,7 @@ fn margin_with_sibling_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() @@ -65,6 +190,7 @@ fn margin_with_sibling_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -73,6 +199,10 @@ fn margin_with_sibling_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,22 +216,135 @@ fn margin_with_sibling_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node0, 45f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node1, 45f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node1, 55f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_height.rs b/tests/generated/flex/max_height.rs index adb13ccad..1274855e3 100644 --- a/tests/generated/flex/max_height.rs +++ b/tests/generated/flex/max_height.rs @@ -6,6 +6,7 @@ fn max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -14,6 +15,10 @@ fn max_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,86 @@ fn max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +123,7 @@ fn max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -59,6 +133,10 @@ fn max_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +150,84 @@ fn max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_height_overrides_height.rs b/tests/generated/flex/max_height_overrides_height.rs index d4a19ff92..8b45c1693 100644 --- a/tests/generated/flex/max_height_overrides_height.rs +++ b/tests/generated/flex/max_height_overrides_height.rs @@ -6,28 +6,114 @@ fn max_height_overrides_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +125,7 @@ fn max_height_overrides_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -46,7 +133,14 @@ fn max_height_overrides_height__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +148,90 @@ fn max_height_overrides_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_height_overrides_height_on_root.rs b/tests/generated/flex/max_height_overrides_height_on_root.rs index ef52ded63..fe9704719 100644 --- a/tests/generated/flex/max_height_overrides_height_on_root.rs +++ b/tests/generated/flex/max_height_overrides_height_on_root.rs @@ -6,6 +6,7 @@ fn max_height_overrides_height_on_root__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -15,12 +16,47 @@ fn max_height_overrides_height_on_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -32,6 +68,7 @@ fn max_height_overrides_height_on_root__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -41,10 +78,45 @@ fn max_height_overrides_height_on_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_width.rs b/tests/generated/flex/max_width.rs index 2d7981f3e..01ebec432 100644 --- a/tests/generated/flex/max_width.rs +++ b/tests/generated/flex/max_width.rs @@ -6,6 +6,7 @@ fn max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -15,6 +16,10 @@ fn max_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -61,6 +135,10 @@ fn max_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_width_overrides_width.rs b/tests/generated/flex/max_width_overrides_width.rs index b3a4cc5a6..6a67b15d8 100644 --- a/tests/generated/flex/max_width_overrides_width.rs +++ b/tests/generated/flex/max_width_overrides_width.rs @@ -6,28 +6,108 @@ fn max_width_overrides_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +119,7 @@ fn max_width_overrides_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -46,7 +127,14 @@ fn max_width_overrides_width__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +142,84 @@ fn max_width_overrides_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/max_width_overrides_width_on_root.rs b/tests/generated/flex/max_width_overrides_width_on_root.rs index 67544bf9c..5783f9a51 100644 --- a/tests/generated/flex/max_width_overrides_width_on_root.rs +++ b/tests/generated/flex/max_width_overrides_width_on_root.rs @@ -6,6 +6,7 @@ fn max_width_overrides_width_on_root__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -15,12 +16,47 @@ fn max_width_overrides_width_on_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -32,6 +68,7 @@ fn max_width_overrides_width_on_root__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -41,10 +78,45 @@ fn max_width_overrides_width_on_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child.rs b/tests/generated/flex/measure_child.rs index 9830fd54b..c30a8fc4c 100644 --- a/tests/generated/flex/measure_child.rs +++ b/tests/generated/flex/measure_child.rs @@ -6,27 +6,112 @@ fn measure_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -37,13 +122,27 @@ fn measure_child__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -51,16 +150,84 @@ fn measure_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_absolute.rs b/tests/generated/flex/measure_child_absolute.rs index b21457532..80f7fc7e5 100644 --- a/tests/generated/flex/measure_child_absolute.rs +++ b/tests/generated/flex/measure_child_absolute.rs @@ -6,13 +6,24 @@ fn measure_child_absolute__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -26,18 +37,86 @@ fn measure_child_absolute__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +130,10 @@ fn measure_child_absolute__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), @@ -60,6 +143,10 @@ fn measure_child_absolute__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -73,16 +160,84 @@ fn measure_child_absolute__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_constraint.rs b/tests/generated/flex/measure_child_constraint.rs index e423669f9..856bd91a1 100644 --- a/tests/generated/flex/measure_child_constraint.rs +++ b/tests/generated/flex/measure_child_constraint.rs @@ -4,10 +4,26 @@ fn measure_child_constraint__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::AUTO, @@ -21,18 +37,92 @@ fn measure_child_constraint__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -41,11 +131,28 @@ fn measure_child_constraint__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::AUTO, @@ -59,16 +166,90 @@ fn measure_child_constraint__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_constraint_padding_parent.rs b/tests/generated/flex/measure_child_constraint_padding_parent.rs index a533b3794..3c3779b05 100644 --- a/tests/generated/flex/measure_child_constraint_padding_parent.rs +++ b/tests/generated/flex/measure_child_constraint_padding_parent.rs @@ -4,10 +4,26 @@ fn measure_child_constraint_padding_parent__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::AUTO, @@ -27,18 +43,92 @@ fn measure_child_constraint_padding_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 60f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,11 +137,28 @@ fn measure_child_constraint_padding_parent__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" , crate :: WritingMode :: Horizontal) ,) . unwrap () ; + let node0_text = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node0_text, crate::WritingMode::Horizontal), + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::AUTO, @@ -71,16 +178,90 @@ fn measure_child_constraint_padding_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node, 70f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 40f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_with_flex_grow.rs b/tests/generated/flex/measure_child_with_flex_grow.rs index d7e6860e2..dbb9591bb 100644 --- a/tests/generated/flex/measure_child_with_flex_grow.rs +++ b/tests/generated/flex/measure_child_with_flex_grow.rs @@ -6,6 +6,7 @@ fn measure_child_with_flex_grow__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,13 +16,23 @@ fn measure_child_with_flex_grow__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("H\u{200b}H\u{200b}H\u{200b}H\u{200b}H", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -35,24 +46,125 @@ fn measure_child_with_flex_grow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +176,7 @@ fn measure_child_with_flex_grow__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -73,7 +186,14 @@ fn measure_child_with_flex_grow__content_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("H\u{200b}H\u{200b}H\u{200b}H\u{200b}H", crate::WritingMode::Horizontal), ) .unwrap(); @@ -81,6 +201,10 @@ fn measure_child_with_flex_grow__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -94,22 +218,123 @@ fn measure_child_with_flex_grow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_with_flex_shrink.rs b/tests/generated/flex/measure_child_with_flex_shrink.rs index 849b0ee65..5f4de5f08 100644 --- a/tests/generated/flex/measure_child_with_flex_shrink.rs +++ b/tests/generated/flex/measure_child_with_flex_shrink.rs @@ -6,6 +6,7 @@ fn measure_child_with_flex_shrink__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,7 +16,13 @@ fn measure_child_with_flex_shrink__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text( "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", crate::WritingMode::Horizontal, @@ -25,6 +32,10 @@ fn measure_child_with_flex_shrink__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -38,24 +49,125 @@ fn measure_child_with_flex_shrink__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +179,7 @@ fn measure_child_with_flex_shrink__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -76,7 +189,14 @@ fn measure_child_with_flex_shrink__content_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text( "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", crate::WritingMode::Horizontal, @@ -87,6 +207,10 @@ fn measure_child_with_flex_shrink__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -100,22 +224,123 @@ fn measure_child_with_flex_shrink__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs b/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs index f36c1e959..2996e2469 100644 --- a/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs +++ b/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs @@ -6,6 +6,7 @@ fn measure_child_with_flex_shrink_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -32,6 +33,10 @@ fn measure_child_with_flex_shrink_hidden__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -45,42 +50,125 @@ fn measure_child_with_flex_shrink_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node1, 91f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node1, 9f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 9f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 9f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 9f32, - layout.scroll_width() - ); + if layout.scroll_width() != 9f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 9f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -92,6 +180,7 @@ fn measure_child_with_flex_shrink_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -120,6 +209,10 @@ fn measure_child_with_flex_shrink_hidden__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::AUTO, @@ -133,40 +226,123 @@ fn measure_child_with_flex_shrink_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node1, 91f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node1, 9f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 9f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 9f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 9f32, - layout.scroll_width() - ); + if layout.scroll_width() != 9f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 9f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs b/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs index 0379f73cf..c34af3f60 100644 --- a/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs +++ b/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs @@ -7,6 +7,10 @@ fn measure_child_with_min_size_greater_than_available_space__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -18,6 +22,10 @@ fn measure_child_with_min_size_greater_than_available_space__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -28,18 +36,86 @@ fn measure_child_with_min_size_greater_than_available_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +128,10 @@ fn measure_child_with_min_size_greater_than_available_space__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -64,6 +144,10 @@ fn measure_child_with_min_size_greater_than_available_space__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -74,16 +158,84 @@ fn measure_child_with_min_size_greater_than_available_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_flex_basis_overrides_measure.rs b/tests/generated/flex/measure_flex_basis_overrides_measure.rs index 7834fb0f5..b658bf2be 100644 --- a/tests/generated/flex/measure_flex_basis_overrides_measure.rs +++ b/tests/generated/flex/measure_flex_basis_overrides_measure.rs @@ -6,13 +6,23 @@ fn measure_flex_basis_overrides_measure__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("H", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -26,18 +36,86 @@ fn measure_flex_basis_overrides_measure__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn measure_flex_basis_overrides_measure__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("H", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn measure_flex_basis_overrides_measure__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -69,16 +158,84 @@ fn measure_flex_basis_overrides_measure__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_height_overrides_measure.rs b/tests/generated/flex/measure_height_overrides_measure.rs index d7dee7fae..eed6d7449 100644 --- a/tests/generated/flex/measure_height_overrides_measure.rs +++ b/tests/generated/flex/measure_height_overrides_measure.rs @@ -7,29 +7,112 @@ fn measure_height_overrides_measure__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(5f32) }, ..Default::default() }, crate::TestNodeContext::ahem_text("H", crate::WritingMode::Horizontal), ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node0, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,6 +125,10 @@ fn measure_height_overrides_measure__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(5f32) }, ..Default::default() }, @@ -50,7 +137,14 @@ fn measure_height_overrides_measure__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -58,16 +152,84 @@ fn measure_height_overrides_measure__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node0, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 5f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_remeasure_child_after_growing.rs b/tests/generated/flex/measure_remeasure_child_after_growing.rs index 14b7dd35e..7d4c5be7b 100644 --- a/tests/generated/flex/measure_remeasure_child_after_growing.rs +++ b/tests/generated/flex/measure_remeasure_child_after_growing.rs @@ -6,6 +6,7 @@ fn measure_remeasure_child_after_growing__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,13 +16,23 @@ fn measure_remeasure_child_after_growing__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -36,24 +47,125 @@ fn measure_remeasure_child_after_growing__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +177,7 @@ fn measure_remeasure_child_after_growing__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -74,7 +187,14 @@ fn measure_remeasure_child_after_growing__content_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -82,6 +202,10 @@ fn measure_remeasure_child_after_growing__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -96,22 +220,123 @@ fn measure_remeasure_child_after_growing__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_remeasure_child_after_shrinking.rs b/tests/generated/flex/measure_remeasure_child_after_shrinking.rs index c6c8a0d22..da5b03c97 100644 --- a/tests/generated/flex/measure_remeasure_child_after_shrinking.rs +++ b/tests/generated/flex/measure_remeasure_child_after_shrinking.rs @@ -6,6 +6,7 @@ fn measure_remeasure_child_after_shrinking__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -16,13 +17,23 @@ fn measure_remeasure_child_after_shrinking__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -37,24 +48,125 @@ fn measure_remeasure_child_after_shrinking__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +178,7 @@ fn measure_remeasure_child_after_shrinking__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -76,7 +189,14 @@ fn measure_remeasure_child_after_shrinking__content_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -84,6 +204,10 @@ fn measure_remeasure_child_after_shrinking__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -98,22 +222,123 @@ fn measure_remeasure_child_after_shrinking__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_remeasure_child_after_stretching.rs b/tests/generated/flex/measure_remeasure_child_after_stretching.rs index 0e9265ce4..73fa15c75 100644 --- a/tests/generated/flex/measure_remeasure_child_after_stretching.rs +++ b/tests/generated/flex/measure_remeasure_child_after_stretching.rs @@ -6,13 +6,23 @@ fn measure_remeasure_child_after_stretching__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -26,18 +36,92 @@ fn measure_remeasure_child_after_stretching__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +132,14 @@ fn measure_remeasure_child_after_stretching__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +147,10 @@ fn measure_remeasure_child_after_stretching__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -69,16 +164,90 @@ fn measure_remeasure_child_after_stretching__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_root.rs b/tests/generated/flex/measure_root.rs index 8360be3d3..d466533e9 100644 --- a/tests/generated/flex/measure_root.rs +++ b/tests/generated/flex/measure_root.rs @@ -6,7 +6,13 @@ fn measure_root__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,12 +20,47 @@ fn measure_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -30,7 +71,14 @@ fn measure_root__content_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -38,10 +86,45 @@ fn measure_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_stretch_overrides_measure.rs b/tests/generated/flex/measure_stretch_overrides_measure.rs index a941f8d65..953c6c52b 100644 --- a/tests/generated/flex/measure_stretch_overrides_measure.rs +++ b/tests/generated/flex/measure_stretch_overrides_measure.rs @@ -6,6 +6,7 @@ fn measure_stretch_overrides_measure__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(5f32), ..Default::default() @@ -14,6 +15,10 @@ fn measure_stretch_overrides_measure__border_box() { let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(5f32), ..Default::default() @@ -24,6 +29,10 @@ fn measure_stretch_overrides_measure__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -37,24 +46,125 @@ fn measure_stretch_overrides_measure__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +176,7 @@ fn measure_stretch_overrides_measure__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(5f32), ..Default::default() @@ -75,6 +186,10 @@ fn measure_stretch_overrides_measure__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(5f32), ..Default::default() @@ -86,6 +201,10 @@ fn measure_stretch_overrides_measure__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(10f32), @@ -99,22 +218,123 @@ fn measure_stretch_overrides_measure__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/measure_width_overrides_measure.rs b/tests/generated/flex/measure_width_overrides_measure.rs index 6f52fd321..9a3a80da2 100644 --- a/tests/generated/flex/measure_width_overrides_measure.rs +++ b/tests/generated/flex/measure_width_overrides_measure.rs @@ -7,29 +7,112 @@ fn measure_width_overrides_measure__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,6 +125,10 @@ fn measure_width_overrides_measure__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -50,7 +137,14 @@ fn measure_width_overrides_measure__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -58,16 +152,84 @@ fn measure_width_overrides_measure__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height.rs b/tests/generated/flex/min_height.rs index 781c78ea8..78fd9007b 100644 --- a/tests/generated/flex/min_height.rs +++ b/tests/generated/flex/min_height.rs @@ -6,16 +6,27 @@ fn min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(60f32) }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,24 +40,125 @@ fn min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +170,7 @@ fn min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(60f32) }, ..Default::default() @@ -66,6 +179,7 @@ fn min_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -75,6 +189,10 @@ fn min_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -88,22 +206,123 @@ fn min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height_larger_than_height.rs b/tests/generated/flex/min_height_larger_than_height.rs index 2125425cf..fc350626f 100644 --- a/tests/generated/flex/min_height_larger_than_height.rs +++ b/tests/generated/flex/min_height_larger_than_height.rs @@ -6,6 +6,7 @@ fn min_height_larger_than_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(25f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -14,6 +15,10 @@ fn min_height_larger_than_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,86 @@ fn min_height_larger_than_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +123,7 @@ fn min_height_larger_than_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(25f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -59,6 +133,10 @@ fn min_height_larger_than_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +150,84 @@ fn min_height_larger_than_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height_overrides_height.rs b/tests/generated/flex/min_height_overrides_height.rs index 8c6b5ea93..4c9e6e19a 100644 --- a/tests/generated/flex/min_height_overrides_height.rs +++ b/tests/generated/flex/min_height_overrides_height.rs @@ -6,28 +6,114 @@ fn min_height_overrides_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +125,7 @@ fn min_height_overrides_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -46,7 +133,14 @@ fn min_height_overrides_height__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +148,90 @@ fn min_height_overrides_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height_overrides_height_on_root.rs b/tests/generated/flex/min_height_overrides_height_on_root.rs index d3958c984..d8222b39c 100644 --- a/tests/generated/flex/min_height_overrides_height_on_root.rs +++ b/tests/generated/flex/min_height_overrides_height_on_root.rs @@ -6,6 +6,7 @@ fn min_height_overrides_height_on_root__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -15,12 +16,47 @@ fn min_height_overrides_height_on_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -32,6 +68,7 @@ fn min_height_overrides_height_on_root__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -41,10 +78,45 @@ fn min_height_overrides_height_on_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height_overrides_max_height.rs b/tests/generated/flex/min_height_overrides_max_height.rs index 344ebf37f..7748c8c54 100644 --- a/tests/generated/flex/min_height_overrides_max_height.rs +++ b/tests/generated/flex/min_height_overrides_max_height.rs @@ -6,28 +6,114 @@ fn min_height_overrides_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +125,7 @@ fn min_height_overrides_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() @@ -46,7 +133,14 @@ fn min_height_overrides_max_height__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +148,90 @@ fn min_height_overrides_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_height_with_nested_fixed_height.rs b/tests/generated/flex/min_height_with_nested_fixed_height.rs index e6c871431..96c89131a 100644 --- a/tests/generated/flex/min_height_with_nested_fixed_height.rs +++ b/tests/generated/flex/min_height_with_nested_fixed_height.rs @@ -6,6 +6,7 @@ fn min_height_with_nested_fixed_height__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -17,6 +18,10 @@ fn min_height_with_nested_fixed_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::FlexStart), flex_shrink: 0f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(28f32) }, @@ -29,6 +34,10 @@ fn min_height_with_nested_fixed_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(44f32) }, padding: taffy::geometry::Rect { @@ -46,24 +55,131 @@ fn min_height_with_nested_fixed_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 57f32, "height of node {:?}. Expected {}. Actual {}", node, 57f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 57f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 57f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node0, 16f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 16f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +191,7 @@ fn min_height_with_nested_fixed_height__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -87,6 +204,10 @@ fn min_height_with_nested_fixed_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::FlexStart), flex_shrink: 0f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(28f32) }, @@ -100,6 +221,10 @@ fn min_height_with_nested_fixed_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(44f32) }, padding: taffy::geometry::Rect { @@ -117,22 +242,129 @@ fn min_height_with_nested_fixed_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 352f32, "width of node {:?}. Expected {}. Actual {}", node, 352f32, size.width); - assert_eq!(size.height, 57f32, "height of node {:?}. Expected {}. Actual {}", node, 57f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 352f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 352f32, layout.size.width); + } + if layout.size.height != 57f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 57f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node0, 16f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 16f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_max_percent_different_width_height.rs b/tests/generated/flex/min_max_percent_different_width_height.rs index a67f50604..dcffacfba 100644 --- a/tests/generated/flex/min_max_percent_different_width_height.rs +++ b/tests/generated/flex/min_max_percent_different_width_height.rs @@ -7,6 +7,10 @@ fn min_max_percent_different_width_height__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.1f32), height: taffy::style::Dimension::from_percent(0.1f32), @@ -24,6 +28,10 @@ fn min_max_percent_different_width_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -38,18 +46,86 @@ fn min_max_percent_different_width_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +138,10 @@ fn min_max_percent_different_width_height__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.1f32), height: taffy::style::Dimension::from_percent(0.1f32), @@ -80,6 +160,10 @@ fn min_max_percent_different_width_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -94,16 +178,84 @@ fn min_max_percent_different_width_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_max_percent_no_width_height.rs b/tests/generated/flex/min_max_percent_no_width_height.rs index 35bd30c2f..5fff04a8f 100644 --- a/tests/generated/flex/min_max_percent_no_width_height.rs +++ b/tests/generated/flex/min_max_percent_no_width_height.rs @@ -6,6 +6,7 @@ fn min_max_percent_no_width_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.1f32), height: taffy::style::Dimension::from_percent(0.1f32), @@ -21,6 +22,10 @@ fn min_max_percent_no_width_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -35,18 +40,86 @@ fn min_max_percent_no_width_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +131,7 @@ fn min_max_percent_no_width_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.1f32), height: taffy::style::Dimension::from_percent(0.1f32), @@ -74,6 +148,10 @@ fn min_max_percent_no_width_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -88,16 +166,84 @@ fn min_max_percent_no_width_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_width.rs b/tests/generated/flex/min_width.rs index 602d6c03f..913c0f5ff 100644 --- a/tests/generated/flex/min_width.rs +++ b/tests/generated/flex/min_width.rs @@ -6,15 +6,26 @@ fn min_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,24 +39,137 @@ fn min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +181,7 @@ fn min_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -65,6 +190,7 @@ fn min_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -73,6 +199,10 @@ fn min_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,22 +216,135 @@ fn min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_width_larger_than_width.rs b/tests/generated/flex/min_width_larger_than_width.rs index 5d31345b5..97d78e1ee 100644 --- a/tests/generated/flex/min_width_larger_than_width.rs +++ b/tests/generated/flex/min_width_larger_than_width.rs @@ -6,6 +6,7 @@ fn min_width_larger_than_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -15,6 +16,10 @@ fn min_width_larger_than_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn min_width_larger_than_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn min_width_larger_than_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -61,6 +135,10 @@ fn min_width_larger_than_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn min_width_larger_than_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_width_overrides_max_width.rs b/tests/generated/flex/min_width_overrides_max_width.rs index 9d26b3c6c..5bac0abc6 100644 --- a/tests/generated/flex/min_width_overrides_max_width.rs +++ b/tests/generated/flex/min_width_overrides_max_width.rs @@ -6,28 +6,108 @@ fn min_width_overrides_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +119,7 @@ fn min_width_overrides_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -46,7 +127,14 @@ fn min_width_overrides_max_width__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +142,84 @@ fn min_width_overrides_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_width_overrides_width.rs b/tests/generated/flex/min_width_overrides_width.rs index 4084f78e6..66d46eda6 100644 --- a/tests/generated/flex/min_width_overrides_width.rs +++ b/tests/generated/flex/min_width_overrides_width.rs @@ -6,28 +6,108 @@ fn min_width_overrides_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -39,6 +119,7 @@ fn min_width_overrides_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -46,7 +127,14 @@ fn min_width_overrides_width__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -54,16 +142,84 @@ fn min_width_overrides_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/min_width_overrides_width_on_root.rs b/tests/generated/flex/min_width_overrides_width_on_root.rs index e8255eac1..4eaed54b1 100644 --- a/tests/generated/flex/min_width_overrides_width_on_root.rs +++ b/tests/generated/flex/min_width_overrides_width_on_root.rs @@ -6,6 +6,7 @@ fn min_width_overrides_width_on_root__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -15,12 +16,47 @@ fn min_width_overrides_width_on_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -32,6 +68,7 @@ fn min_width_overrides_width_on_root__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -41,10 +78,45 @@ fn min_width_overrides_width_on_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/mod.rs b/tests/generated/flex/mod.rs index 2da7e914e..ce63118a1 100644 --- a/tests/generated/flex/mod.rs +++ b/tests/generated/flex/mod.rs @@ -204,6 +204,7 @@ mod child_min_max_width_flexing; mod child_with_padding_align_end; mod container_with_unsized_child; mod content_size; +mod content_size_with_border; mod display_none; mod display_none_absolute_child; mod display_none_fixed_size; @@ -213,6 +214,10 @@ mod display_none_with_margin; mod display_none_with_position; mod display_none_with_position_absolute; mod do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent; +mod flex_absolute_overflow_clip; +mod flex_absolute_overflow_hidden; +mod flex_absolute_overflow_scroll; +mod flex_absolute_overflow_visible; mod flex_basis_and_main_dimen_set_when_flexing; mod flex_basis_flex_grow_column; mod flex_basis_flex_grow_row; @@ -257,6 +262,10 @@ mod flex_grow_within_constrained_min_column; mod flex_grow_within_constrained_min_max_column; mod flex_grow_within_constrained_min_row; mod flex_grow_within_max_width; +mod flex_inflow_overflow_clip; +mod flex_inflow_overflow_hidden; +mod flex_inflow_overflow_scroll; +mod flex_inflow_overflow_visible; mod flex_root_ignored; mod flex_row_relative_all_sides; mod flex_shrink_by_outer_margin_with_max_size; diff --git a/tests/generated/flex/multiline_column_max_height.rs b/tests/generated/flex/multiline_column_max_height.rs index 6f3899eaf..69a897ba0 100644 --- a/tests/generated/flex/multiline_column_max_height.rs +++ b/tests/generated/flex/multiline_column_max_height.rs @@ -6,6 +6,7 @@ fn multiline_column_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -16,6 +17,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -26,6 +28,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -36,6 +39,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -46,6 +50,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -56,6 +61,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -66,6 +72,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -76,6 +83,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -86,6 +94,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node8 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -96,6 +105,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node9 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -106,6 +116,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -116,6 +127,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -126,6 +138,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -136,6 +149,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node13 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -146,6 +160,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node14 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -156,6 +171,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node15 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -166,6 +182,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node16 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -176,6 +193,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node17 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -186,6 +204,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node18 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -196,6 +215,7 @@ fn multiline_column_max_height__border_box() { .unwrap(); let node19 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -210,6 +230,10 @@ fn multiline_column_max_height__border_box() { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() }, @@ -223,132 +247,887 @@ fn multiline_column_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node16).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node17).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node18).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node19).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -360,6 +1139,7 @@ fn multiline_column_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -371,6 +1151,7 @@ fn multiline_column_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -382,6 +1163,7 @@ fn multiline_column_max_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -393,6 +1175,7 @@ fn multiline_column_max_height__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -404,6 +1187,7 @@ fn multiline_column_max_height__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -415,6 +1199,7 @@ fn multiline_column_max_height__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -426,6 +1211,7 @@ fn multiline_column_max_height__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -437,6 +1223,7 @@ fn multiline_column_max_height__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -448,6 +1235,7 @@ fn multiline_column_max_height__content_box() { let node8 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -459,6 +1247,7 @@ fn multiline_column_max_height__content_box() { let node9 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -470,6 +1259,7 @@ fn multiline_column_max_height__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -481,6 +1271,7 @@ fn multiline_column_max_height__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -492,6 +1283,7 @@ fn multiline_column_max_height__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -503,6 +1295,7 @@ fn multiline_column_max_height__content_box() { let node13 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -514,6 +1307,7 @@ fn multiline_column_max_height__content_box() { let node14 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -525,6 +1319,7 @@ fn multiline_column_max_height__content_box() { let node15 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -536,6 +1331,7 @@ fn multiline_column_max_height__content_box() { let node16 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -547,6 +1343,7 @@ fn multiline_column_max_height__content_box() { let node17 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -558,6 +1355,7 @@ fn multiline_column_max_height__content_box() { let node18 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -569,6 +1367,7 @@ fn multiline_column_max_height__content_box() { let node19 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), @@ -584,6 +1383,10 @@ fn multiline_column_max_height__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() }, @@ -597,130 +1400,885 @@ fn multiline_column_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node16).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node16, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node16, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node17).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node17, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node17, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node18).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node18, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node18, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node19).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node19, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node19, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/multiline_min_max_12.rs b/tests/generated/flex/multiline_min_max_12.rs index 24787efc8..e1f29cb3b 100644 --- a/tests/generated/flex/multiline_min_max_12.rs +++ b/tests/generated/flex/multiline_min_max_12.rs @@ -6,6 +6,7 @@ fn multiline_min_max_12__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -17,6 +18,7 @@ fn multiline_min_max_12__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -29,6 +31,7 @@ fn multiline_min_max_12__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -41,6 +44,7 @@ fn multiline_min_max_12__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -57,6 +61,10 @@ fn multiline_min_max_12__border_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -76,36 +84,203 @@ fn multiline_min_max_12__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -116,6 +291,7 @@ fn multiline_min_max_12__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -127,6 +303,7 @@ fn multiline_min_max_12__content_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -139,6 +316,7 @@ fn multiline_min_max_12__content_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -151,6 +329,7 @@ fn multiline_min_max_12__content_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -167,6 +346,10 @@ fn multiline_min_max_12__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -186,34 +369,201 @@ fn multiline_min_max_12__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/multiline_min_max_13.rs b/tests/generated/flex/multiline_min_max_13.rs index f64357181..43a416146 100644 --- a/tests/generated/flex/multiline_min_max_13.rs +++ b/tests/generated/flex/multiline_min_max_13.rs @@ -6,6 +6,7 @@ fn multiline_min_max_13__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -17,6 +18,7 @@ fn multiline_min_max_13__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -29,6 +31,7 @@ fn multiline_min_max_13__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -41,6 +44,7 @@ fn multiline_min_max_13__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -57,6 +61,10 @@ fn multiline_min_max_13__border_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -76,36 +84,203 @@ fn multiline_min_max_13__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -116,6 +291,7 @@ fn multiline_min_max_13__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -127,6 +303,7 @@ fn multiline_min_max_13__content_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -139,6 +316,7 @@ fn multiline_min_max_13__content_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -151,6 +329,7 @@ fn multiline_min_max_13__content_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -167,6 +346,10 @@ fn multiline_min_max_13__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -186,34 +369,201 @@ fn multiline_min_max_13__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/multiline_min_max_14.rs b/tests/generated/flex/multiline_min_max_14.rs index f8baf2e25..205ab2349 100644 --- a/tests/generated/flex/multiline_min_max_14.rs +++ b/tests/generated/flex/multiline_min_max_14.rs @@ -6,6 +6,7 @@ fn multiline_min_max_14__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -17,6 +18,7 @@ fn multiline_min_max_14__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -29,6 +31,7 @@ fn multiline_min_max_14__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -41,6 +44,7 @@ fn multiline_min_max_14__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -57,6 +61,10 @@ fn multiline_min_max_14__border_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -76,36 +84,203 @@ fn multiline_min_max_14__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node1, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 315f32, "x of node {:?}. Expected {}. Actual {}", node1, 315f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 315f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 315f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node2, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 460f32, "x of node {:?}. Expected {}. Actual {}", node2, 460f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 460f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 460f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node3, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node3, 15f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -116,6 +291,7 @@ fn multiline_min_max_14__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -127,6 +303,7 @@ fn multiline_min_max_14__content_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -139,6 +316,7 @@ fn multiline_min_max_14__content_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -151,6 +329,7 @@ fn multiline_min_max_14__content_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -167,6 +346,10 @@ fn multiline_min_max_14__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -186,34 +369,201 @@ fn multiline_min_max_14__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node1, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 315f32, "x of node {:?}. Expected {}. Actual {}", node1, 315f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 315f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 315f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node2, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 460f32, "x of node {:?}. Expected {}. Actual {}", node2, 460f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 460f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 460f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node3, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node3, 15f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/multiline_min_max_5.rs b/tests/generated/flex/multiline_min_max_5.rs index 94ea90a4a..e8609e3e4 100644 --- a/tests/generated/flex/multiline_min_max_5.rs +++ b/tests/generated/flex/multiline_min_max_5.rs @@ -7,6 +7,7 @@ fn multiline_min_max_5__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -18,6 +19,7 @@ fn multiline_min_max_5__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -31,6 +33,7 @@ fn multiline_min_max_5__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -44,6 +47,7 @@ fn multiline_min_max_5__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -60,6 +64,10 @@ fn multiline_min_max_5__border_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -79,36 +87,203 @@ fn multiline_min_max_5__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -120,6 +295,7 @@ fn multiline_min_max_5__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -131,6 +307,7 @@ fn multiline_min_max_5__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -144,6 +321,7 @@ fn multiline_min_max_5__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -157,6 +335,7 @@ fn multiline_min_max_5__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -173,6 +352,10 @@ fn multiline_min_max_5__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -192,34 +375,201 @@ fn multiline_min_max_5__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 305f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 305f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 405f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 405f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 505f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 505f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/multiline_min_max_8.rs b/tests/generated/flex/multiline_min_max_8.rs index 22e2aad10..61293b2a2 100644 --- a/tests/generated/flex/multiline_min_max_8.rs +++ b/tests/generated/flex/multiline_min_max_8.rs @@ -6,6 +6,7 @@ fn multiline_min_max_8__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -17,6 +18,7 @@ fn multiline_min_max_8__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -29,6 +31,7 @@ fn multiline_min_max_8__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -41,6 +44,7 @@ fn multiline_min_max_8__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -57,6 +61,10 @@ fn multiline_min_max_8__border_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -76,36 +84,203 @@ fn multiline_min_max_8__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node1, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 315f32, "x of node {:?}. Expected {}. Actual {}", node1, 315f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 315f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 315f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node2, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 460f32, "x of node {:?}. Expected {}. Actual {}", node2, 460f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 460f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 460f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node3, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node3, 15f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -117,6 +292,7 @@ fn multiline_min_max_8__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(600f32), @@ -129,6 +305,7 @@ fn multiline_min_max_8__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -142,6 +319,7 @@ fn multiline_min_max_8__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -155,6 +333,7 @@ fn multiline_min_max_8__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::AUTO, @@ -171,6 +350,10 @@ fn multiline_min_max_8__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: taffy::style::Dimension::from_length(20f32), @@ -190,34 +373,201 @@ fn multiline_min_max_8__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 610f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 610f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node1, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 315f32, "x of node {:?}. Expected {}. Actual {}", node1, 315f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 315f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 315f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node2, 145f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 460f32, "x of node {:?}. Expected {}. Actual {}", node2, 460f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 460f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 460f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node3, 600f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node3, 15f32, location.y); + if layout.size.width != 600f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 600f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/nested_overflowing_child.rs b/tests/generated/flex/nested_overflowing_child.rs index a073fbf33..511c1a481 100644 --- a/tests/generated/flex/nested_overflowing_child.rs +++ b/tests/generated/flex/nested_overflowing_child.rs @@ -6,6 +6,7 @@ fn nested_overflowing_child__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -13,10 +14,25 @@ fn nested_overflowing_child__border_box() { ..Default::default() }) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -30,24 +46,137 @@ fn nested_overflowing_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +188,7 @@ fn nested_overflowing_child__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -68,7 +198,14 @@ fn nested_overflowing_child__content_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -76,6 +213,10 @@ fn nested_overflowing_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -89,22 +230,135 @@ fn nested_overflowing_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs b/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs index cfd2c9732..8a71b5a63 100644 --- a/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs +++ b/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs @@ -6,6 +6,7 @@ fn nested_overflowing_child_in_constraint_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -16,6 +17,10 @@ fn nested_overflowing_child_in_constraint_parent__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,6 +33,10 @@ fn nested_overflowing_child_in_constraint_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -41,24 +50,137 @@ fn nested_overflowing_child_in_constraint_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -70,6 +192,7 @@ fn nested_overflowing_child_in_constraint_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -81,6 +204,10 @@ fn nested_overflowing_child_in_constraint_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -94,6 +221,10 @@ fn nested_overflowing_child_in_constraint_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -107,22 +238,135 @@ fn nested_overflowing_child_in_constraint_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs b/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs index 7940dfb7b..e267e0aa5 100644 --- a/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs +++ b/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs @@ -6,6 +6,7 @@ fn only_shrinkable_item_with_flex_basis_zero__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -13,6 +14,7 @@ fn only_shrinkable_item_with_flex_basis_zero__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(93f32), margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(6f32) }, @@ -21,6 +23,7 @@ fn only_shrinkable_item_with_flex_basis_zero__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(764f32), ..Default::default() @@ -30,6 +33,10 @@ fn only_shrinkable_item_with_flex_basis_zero__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(480f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(764f32) }, ..Default::default() @@ -41,30 +48,170 @@ fn only_shrinkable_item_with_flex_basis_zero__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node, 480f32, size.width); - assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node, 764f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 764f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 764f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 99f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 99f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node0, 480f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node1, 480f32, size.width); - assert_eq!(size.height, 93f32, "height of node {:?}. Expected {}. Actual {}", node1, 93f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 93f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 93f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node2, 480f32, size.width); - assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node2, 764f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 99f32, "y of node {:?}. Expected {}. Actual {}", node2, 99f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 764f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 764f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 99f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -76,6 +223,7 @@ fn only_shrinkable_item_with_flex_basis_zero__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() @@ -84,6 +232,7 @@ fn only_shrinkable_item_with_flex_basis_zero__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(93f32), margin: taffy::geometry::Rect { left: zero(), right: zero(), top: zero(), bottom: length(6f32) }, @@ -93,6 +242,7 @@ fn only_shrinkable_item_with_flex_basis_zero__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(764f32), ..Default::default() @@ -103,6 +253,10 @@ fn only_shrinkable_item_with_flex_basis_zero__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(480f32), height: auto() }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(764f32) }, ..Default::default() @@ -114,28 +268,168 @@ fn only_shrinkable_item_with_flex_basis_zero__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node, 480f32, size.width); - assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node, 764f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 764f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 764f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 99f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 99f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node0, 480f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node1, 480f32, size.width); - assert_eq!(size.height, 93f32, "height of node {:?}. Expected {}. Actual {}", node1, 93f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 93f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 93f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node2, 480f32, size.width); - assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node2, 764f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 99f32, "y of node {:?}. Expected {}. Actual {}", node2, 99f32, location.y); + if layout.size.width != 480f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 480f32, layout.size.width); + } + if layout.size.height != 764f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 764f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 99f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_cross_axis.rs b/tests/generated/flex/overflow_cross_axis.rs index 51dafb5af..c0979f3ad 100644 --- a/tests/generated/flex/overflow_cross_axis.rs +++ b/tests/generated/flex/overflow_cross_axis.rs @@ -6,6 +6,7 @@ fn overflow_cross_axis__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -16,6 +17,10 @@ fn overflow_cross_axis__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -29,18 +34,92 @@ fn overflow_cross_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +131,7 @@ fn overflow_cross_axis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -63,6 +143,10 @@ fn overflow_cross_axis__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -76,16 +160,90 @@ fn overflow_cross_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_main_axis.rs b/tests/generated/flex/overflow_main_axis.rs index 448105755..7b835c495 100644 --- a/tests/generated/flex/overflow_main_axis.rs +++ b/tests/generated/flex/overflow_main_axis.rs @@ -6,6 +6,7 @@ fn overflow_main_axis__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() @@ -14,6 +15,10 @@ fn overflow_main_axis__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -27,18 +32,92 @@ fn overflow_main_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +129,7 @@ fn overflow_main_axis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() @@ -59,6 +139,10 @@ fn overflow_main_axis__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,16 +156,90 @@ fn overflow_main_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 100f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_main_axis_shrink_hidden.rs b/tests/generated/flex/overflow_main_axis_shrink_hidden.rs index 42170a0f4..06dbbd614 100644 --- a/tests/generated/flex/overflow_main_axis_shrink_hidden.rs +++ b/tests/generated/flex/overflow_main_axis_shrink_hidden.rs @@ -21,6 +21,10 @@ fn overflow_main_axis_shrink_hidden__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,36 +38,86 @@ fn overflow_main_axis_shrink_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +145,10 @@ fn overflow_main_axis_shrink_hidden__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,34 +162,84 @@ fn overflow_main_axis_shrink_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_main_axis_shrink_scroll.rs b/tests/generated/flex/overflow_main_axis_shrink_scroll.rs index 5de6c7913..363d7d65d 100644 --- a/tests/generated/flex/overflow_main_axis_shrink_scroll.rs +++ b/tests/generated/flex/overflow_main_axis_shrink_scroll.rs @@ -21,6 +21,10 @@ fn overflow_main_axis_shrink_scroll__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,36 +38,86 @@ fn overflow_main_axis_shrink_scroll__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +145,10 @@ fn overflow_main_axis_shrink_scroll__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,34 +162,84 @@ fn overflow_main_axis_shrink_scroll__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_main_axis_shrink_visible.rs b/tests/generated/flex/overflow_main_axis_shrink_visible.rs index e589a1ad0..fdaaa216c 100644 --- a/tests/generated/flex/overflow_main_axis_shrink_visible.rs +++ b/tests/generated/flex/overflow_main_axis_shrink_visible.rs @@ -6,13 +6,24 @@ fn overflow_main_axis_shrink_visible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { flex_shrink: 1f32, ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_shrink: 1f32, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -26,18 +37,86 @@ fn overflow_main_axis_shrink_visible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -50,6 +129,10 @@ fn overflow_main_axis_shrink_visible__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_shrink: 1f32, ..Default::default() }, @@ -60,6 +143,10 @@ fn overflow_main_axis_shrink_visible__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -73,16 +160,84 @@ fn overflow_main_axis_shrink_visible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs b/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs index bb6b77a1b..58ac1d3a9 100644 --- a/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs +++ b/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs @@ -6,6 +6,7 @@ fn overflow_scroll_main_axis_justify_content_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() @@ -14,6 +15,10 @@ fn overflow_scroll_main_axis_justify_content_end__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,92 @@ fn overflow_scroll_main_axis_justify_content_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +130,7 @@ fn overflow_scroll_main_axis_justify_content_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() @@ -60,6 +140,10 @@ fn overflow_scroll_main_axis_justify_content_end__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -74,16 +158,90 @@ fn overflow_scroll_main_axis_justify_content_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs b/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs index b4291b2a9..8534ed6bb 100644 --- a/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs +++ b/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_overridden_by_available_space__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { @@ -22,6 +28,10 @@ fn overflow_scrollbars_overridden_by_available_space__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -35,42 +45,125 @@ fn overflow_scrollbars_overridden_by_available_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,6 +175,7 @@ fn overflow_scrollbars_overridden_by_available_space__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -105,6 +199,10 @@ fn overflow_scrollbars_overridden_by_available_space__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -118,40 +216,123 @@ fn overflow_scrollbars_overridden_by_available_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs b/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs index 5a994e0e1..957fa4a60 100644 --- a/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs +++ b/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_overridden_by_max_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -26,36 +32,86 @@ fn overflow_scrollbars_overridden_by_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +123,7 @@ fn overflow_scrollbars_overridden_by_max_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,34 +150,84 @@ fn overflow_scrollbars_overridden_by_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs b/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs index 36ee9e94b..4b9a4b9db 100644 --- a/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs +++ b/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_overridden_by_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -26,36 +32,86 @@ fn overflow_scrollbars_overridden_by_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +123,7 @@ fn overflow_scrollbars_overridden_by_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,34 +150,84 @@ fn overflow_scrollbars_overridden_by_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs index 01d51183e..4d785a56d 100644 --- a/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_take_up_space_both_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -26,36 +32,86 @@ fn overflow_scrollbars_take_up_space_both_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +123,7 @@ fn overflow_scrollbars_take_up_space_both_axis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,34 +150,84 @@ fn overflow_scrollbars_take_up_space_both_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs b/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs index e54e063c3..9b102f593 100644 --- a/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs +++ b/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_take_up_space_cross_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -26,36 +32,86 @@ fn overflow_scrollbars_take_up_space_cross_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +123,7 @@ fn overflow_scrollbars_take_up_space_cross_axis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,34 +150,84 @@ fn overflow_scrollbars_take_up_space_cross_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs b/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs index d424affbf..b883e974f 100644 --- a/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs +++ b/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs @@ -4,7 +4,13 @@ fn overflow_scrollbars_take_up_space_main_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -26,36 +32,86 @@ fn overflow_scrollbars_take_up_space_main_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +123,7 @@ fn overflow_scrollbars_take_up_space_main_axis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,34 +150,84 @@ fn overflow_scrollbars_take_up_space_main_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_align_end_child.rs b/tests/generated/flex/padding_align_end_child.rs index c4127e7ac..46fb5ad3d 100644 --- a/tests/generated/flex/padding_align_end_child.rs +++ b/tests/generated/flex/padding_align_end_child.rs @@ -6,6 +6,7 @@ fn padding_align_end_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -22,6 +23,10 @@ fn padding_align_end_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -37,18 +42,92 @@ fn padding_align_end_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +139,7 @@ fn padding_align_end_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -77,6 +157,10 @@ fn padding_align_end_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { @@ -92,16 +176,90 @@ fn padding_align_end_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_border_overrides_max_size.rs b/tests/generated/flex/padding_border_overrides_max_size.rs index 7ab96f984..888221706 100644 --- a/tests/generated/flex/padding_border_overrides_max_size.rs +++ b/tests/generated/flex/padding_border_overrides_max_size.rs @@ -6,6 +6,7 @@ fn padding_border_overrides_max_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -25,23 +26,102 @@ fn padding_border_overrides_max_size__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +133,7 @@ fn padding_border_overrides_max_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -74,7 +155,14 @@ fn padding_border_overrides_max_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -82,16 +170,84 @@ fn padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_border_overrides_min_size.rs b/tests/generated/flex/padding_border_overrides_min_size.rs index 776e123af..651fb7e8d 100644 --- a/tests/generated/flex/padding_border_overrides_min_size.rs +++ b/tests/generated/flex/padding_border_overrides_min_size.rs @@ -6,6 +6,7 @@ fn padding_border_overrides_min_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -25,23 +26,102 @@ fn padding_border_overrides_min_size__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +133,7 @@ fn padding_border_overrides_min_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -74,7 +155,14 @@ fn padding_border_overrides_min_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -82,16 +170,84 @@ fn padding_border_overrides_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_border_overrides_size.rs b/tests/generated/flex/padding_border_overrides_size.rs index 7e73f40fb..935afa973 100644 --- a/tests/generated/flex/padding_border_overrides_size.rs +++ b/tests/generated/flex/padding_border_overrides_size.rs @@ -6,6 +6,7 @@ fn padding_border_overrides_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -25,23 +26,102 @@ fn padding_border_overrides_size__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +133,7 @@ fn padding_border_overrides_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -74,7 +155,14 @@ fn padding_border_overrides_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -82,16 +170,84 @@ fn padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs b/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs index 12912b0e8..4220c70ac 100644 --- a/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs +++ b/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs @@ -6,6 +6,7 @@ fn padding_border_overrides_size_flex_basis_0_growable__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { @@ -29,6 +30,7 @@ fn padding_border_overrides_size_flex_basis_0_growable__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { @@ -38,29 +40,141 @@ fn padding_border_overrides_size_flex_basis_0_growable__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 6f32, "width of node {:?}. Expected {}. Actual {}", node1, 6f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1, 12f32, size.height); - assert_eq!(location.x, 28f32, "x of node {:?}. Expected {}. Actual {}", node1, 28f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 6f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 28f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,6 +186,7 @@ fn padding_border_overrides_size_flex_basis_0_growable__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { @@ -96,6 +211,7 @@ fn padding_border_overrides_size_flex_basis_0_growable__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), size: taffy::geometry::Size { @@ -107,7 +223,14 @@ fn padding_border_overrides_size_flex_basis_0_growable__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -115,22 +238,123 @@ fn padding_border_overrides_size_flex_basis_0_growable__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 46f32, "width of node {:?}. Expected {}. Actual {}", node, 46f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 46f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 46f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node1, 12f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1, 12f32, size.height); - assert_eq!(location.x, 34f32, "x of node {:?}. Expected {}. Actual {}", node1, 34f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 34f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_border_overrides_size_root.rs b/tests/generated/flex/padding_border_overrides_size_root.rs index ce7a771c5..65ac09859 100644 --- a/tests/generated/flex/padding_border_overrides_size_root.rs +++ b/tests/generated/flex/padding_border_overrides_size_root.rs @@ -4,10 +4,19 @@ fn padding_border_overrides_size_root__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -33,18 +42,86 @@ fn padding_border_overrides_size_root__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,12 +131,20 @@ fn padding_border_overrides_size_root__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -85,16 +170,84 @@ fn padding_border_overrides_size_root__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_center_child.rs b/tests/generated/flex/padding_center_child.rs index 046cf43c6..2b1d06b6f 100644 --- a/tests/generated/flex/padding_center_child.rs +++ b/tests/generated/flex/padding_center_child.rs @@ -6,6 +6,7 @@ fn padding_center_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn padding_center_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -37,18 +42,86 @@ fn padding_center_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -60,6 +133,7 @@ fn padding_center_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +145,10 @@ fn padding_center_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -92,16 +170,84 @@ fn padding_center_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); - assert_eq!(size.height, 130f32, "height of node {:?}. Expected {}. Actual {}", node, 130f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 130f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node0, 55f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node0, 55f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 55f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_container_match_child.rs b/tests/generated/flex/padding_container_match_child.rs index 87bd58f38..9f2cfe03f 100644 --- a/tests/generated/flex/padding_container_match_child.rs +++ b/tests/generated/flex/padding_container_match_child.rs @@ -6,6 +6,7 @@ fn padding_container_match_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn padding_container_match_child__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -32,18 +37,86 @@ fn padding_container_match_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn padding_container_match_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -67,6 +141,10 @@ fn padding_container_match_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -82,16 +160,84 @@ fn padding_container_match_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_flex_child.rs b/tests/generated/flex/padding_flex_child.rs index 1f2dec5db..5fdadd3a8 100644 --- a/tests/generated/flex/padding_flex_child.rs +++ b/tests/generated/flex/padding_flex_child.rs @@ -6,6 +6,7 @@ fn padding_flex_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -14,6 +15,10 @@ fn padding_flex_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,86 @@ fn padding_flex_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn padding_flex_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -65,6 +139,10 @@ fn padding_flex_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +162,90 @@ fn padding_flex_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_no_child.rs b/tests/generated/flex/padding_no_child.rs index 49f53570c..71094fedf 100644 --- a/tests/generated/flex/padding_no_child.rs +++ b/tests/generated/flex/padding_no_child.rs @@ -6,6 +6,7 @@ fn padding_no_child__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -19,12 +20,47 @@ fn padding_no_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -36,6 +72,7 @@ fn padding_no_child__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -49,10 +86,45 @@ fn padding_no_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_no_size.rs b/tests/generated/flex/padding_no_size.rs index 6f4e6dcae..549665a7f 100644 --- a/tests/generated/flex/padding_no_size.rs +++ b/tests/generated/flex/padding_no_size.rs @@ -6,6 +6,7 @@ fn padding_no_size__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -19,12 +20,47 @@ fn padding_no_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -36,6 +72,7 @@ fn padding_no_size__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -49,10 +86,45 @@ fn padding_no_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/padding_stretch_child.rs b/tests/generated/flex/padding_stretch_child.rs index 07c7ac939..24fe30fc6 100644 --- a/tests/generated/flex/padding_stretch_child.rs +++ b/tests/generated/flex/padding_stretch_child.rs @@ -6,6 +6,7 @@ fn padding_stretch_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -13,6 +14,10 @@ fn padding_stretch_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn padding_stretch_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +128,7 @@ fn padding_stretch_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -63,6 +137,10 @@ fn padding_stretch_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn padding_stretch_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs b/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs index 63b7ec0e5..7cd727181 100644 --- a/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs +++ b/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs @@ -6,6 +6,7 @@ fn parent_wrap_child_size_overflowing_parent__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -16,6 +17,10 @@ fn parent_wrap_child_size_overflowing_parent__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -25,6 +30,10 @@ fn parent_wrap_child_size_overflowing_parent__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -38,24 +47,137 @@ fn parent_wrap_child_size_overflowing_parent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +189,7 @@ fn parent_wrap_child_size_overflowing_parent__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(200f32), @@ -78,6 +201,10 @@ fn parent_wrap_child_size_overflowing_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -88,6 +215,10 @@ fn parent_wrap_child_size_overflowing_parent__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -101,22 +232,135 @@ fn parent_wrap_child_size_overflowing_parent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percent_absolute_position.rs b/tests/generated/flex/percent_absolute_position.rs index 6d7dc69b8..64359ebe3 100644 --- a/tests/generated/flex/percent_absolute_position.rs +++ b/tests/generated/flex/percent_absolute_position.rs @@ -6,12 +6,14 @@ fn percent_absolute_position__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) @@ -20,6 +22,10 @@ fn percent_absolute_position__border_box() { .new_with_children( taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,6 +40,10 @@ fn percent_absolute_position__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(50f32), @@ -47,30 +57,176 @@ fn percent_absolute_position__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 30f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node01, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -82,6 +238,7 @@ fn percent_absolute_position__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) @@ -89,6 +246,7 @@ fn percent_absolute_position__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) @@ -98,6 +256,10 @@ fn percent_absolute_position__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(50f32), @@ -113,6 +275,10 @@ fn percent_absolute_position__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: taffy::style::Dimension::from_length(50f32), @@ -126,28 +292,174 @@ fn percent_absolute_position__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 30f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node01, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percent_within_flex_grow.rs b/tests/generated/flex/percent_within_flex_grow.rs index f2f33820b..9f901124f 100644 --- a/tests/generated/flex/percent_within_flex_grow.rs +++ b/tests/generated/flex/percent_within_flex_grow.rs @@ -6,12 +6,14 @@ fn percent_within_flex_grow__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) @@ -20,6 +22,10 @@ fn percent_within_flex_grow__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -28,6 +34,7 @@ fn percent_within_flex_grow__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) @@ -35,6 +42,10 @@ fn percent_within_flex_grow__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(350f32), height: taffy::style::Dimension::from_length(100f32), @@ -48,36 +59,221 @@ fn percent_within_flex_grow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 350f32, "width of node {:?}. Expected {}. Actual {}", node, 350f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 350f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 350f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node1, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node10, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node2, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +285,7 @@ fn percent_within_flex_grow__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) @@ -96,6 +293,7 @@ fn percent_within_flex_grow__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() }) @@ -105,6 +303,10 @@ fn percent_within_flex_grow__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, ..Default::default() }, @@ -114,6 +316,7 @@ fn percent_within_flex_grow__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) @@ -122,6 +325,10 @@ fn percent_within_flex_grow__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(350f32), height: taffy::style::Dimension::from_length(100f32), @@ -135,34 +342,219 @@ fn percent_within_flex_grow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 350f32, "width of node {:?}. Expected {}. Actual {}", node, 350f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 350f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 350f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node1, 150f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node10, 150f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node2, 250f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_absolute_position.rs b/tests/generated/flex/percentage_absolute_position.rs index a5201b33c..d670318d9 100644 --- a/tests/generated/flex/percentage_absolute_position.rs +++ b/tests/generated/flex/percentage_absolute_position.rs @@ -7,6 +7,7 @@ fn percentage_absolute_position__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -19,6 +20,10 @@ fn percentage_absolute_position__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,18 +37,86 @@ fn percentage_absolute_position__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +129,7 @@ fn percentage_absolute_position__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -69,6 +143,10 @@ fn percentage_absolute_position__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -82,16 +160,84 @@ fn percentage_absolute_position__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_container_in_wrapping_container.rs b/tests/generated/flex/percentage_container_in_wrapping_container.rs index dd4c7e5c3..55e7053ee 100644 --- a/tests/generated/flex/percentage_container_in_wrapping_container.rs +++ b/tests/generated/flex/percentage_container_in_wrapping_container.rs @@ -6,6 +6,7 @@ fn percentage_container_in_wrapping_container__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -15,6 +16,7 @@ fn percentage_container_in_wrapping_container__border_box() { .unwrap(); let node001 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -25,6 +27,10 @@ fn percentage_container_in_wrapping_container__border_box() { let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -34,7 +40,14 @@ fn percentage_container_in_wrapping_container__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -42,6 +55,10 @@ fn percentage_container_in_wrapping_container__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -57,36 +74,221 @@ fn percentage_container_in_wrapping_container__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node000, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node001, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node001, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +300,7 @@ fn percentage_container_in_wrapping_container__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -108,6 +311,7 @@ fn percentage_container_in_wrapping_container__content_box() { let node001 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -119,6 +323,10 @@ fn percentage_container_in_wrapping_container__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -131,6 +339,10 @@ fn percentage_container_in_wrapping_container__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -141,6 +353,10 @@ fn percentage_container_in_wrapping_container__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { @@ -156,34 +372,219 @@ fn percentage_container_in_wrapping_container__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 75f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node000, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node001, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node001, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 50f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_different_width_height.rs b/tests/generated/flex/percentage_different_width_height.rs index 7992cf36f..247874868 100644 --- a/tests/generated/flex/percentage_different_width_height.rs +++ b/tests/generated/flex/percentage_different_width_height.rs @@ -6,6 +6,7 @@ fn percentage_different_width_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn percentage_different_width_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() }) @@ -20,6 +22,10 @@ fn percentage_different_width_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(300f32), @@ -33,24 +39,125 @@ fn percentage_different_width_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +169,7 @@ fn percentage_different_width_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() @@ -70,6 +178,7 @@ fn percentage_different_width_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() }) @@ -78,6 +187,10 @@ fn percentage_different_width_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(300f32), @@ -91,22 +204,123 @@ fn percentage_different_width_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_different_width_height_column.rs b/tests/generated/flex/percentage_different_width_height_column.rs index 54131cc88..7b850f877 100644 --- a/tests/generated/flex/percentage_different_width_height_column.rs +++ b/tests/generated/flex/percentage_different_width_height_column.rs @@ -4,9 +4,16 @@ fn percentage_different_width_height_column__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() }) @@ -15,6 +22,10 @@ fn percentage_different_width_height_column__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(300f32), @@ -28,24 +39,131 @@ fn percentage_different_width_height_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 210f32, "y of node {:?}. Expected {}. Actual {}", node1, 210f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 210f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 210f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,6 +175,7 @@ fn percentage_different_width_height_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -64,6 +183,7 @@ fn percentage_different_width_height_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.3f32) }, ..Default::default() }) @@ -73,6 +193,10 @@ fn percentage_different_width_height_column__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,22 +210,129 @@ fn percentage_different_width_height_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 210f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 210f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 210f32, "y of node {:?}. Expected {}. Actual {}", node1, 210f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 210f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 210f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis.rs b/tests/generated/flex/percentage_flex_basis.rs index e682a6cb2..2e4c75bc1 100644 --- a/tests/generated/flex/percentage_flex_basis.rs +++ b/tests/generated/flex/percentage_flex_basis.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), ..Default::default() @@ -13,6 +14,7 @@ fn percentage_flex_basis__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.25f32), ..Default::default() @@ -21,6 +23,10 @@ fn percentage_flex_basis__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -34,24 +40,137 @@ fn percentage_flex_basis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 125f32, "width of node {:?}. Expected {}. Actual {}", node0, 125f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 125f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 125f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node1, 75f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 125f32, "x of node {:?}. Expected {}. Actual {}", node1, 125f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 125f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 125f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,6 +182,7 @@ fn percentage_flex_basis__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), ..Default::default() @@ -71,6 +191,7 @@ fn percentage_flex_basis__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.25f32), ..Default::default() @@ -80,6 +201,10 @@ fn percentage_flex_basis__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -93,22 +218,135 @@ fn percentage_flex_basis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 125f32, "width of node {:?}. Expected {}. Actual {}", node0, 125f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 125f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 125f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node1, 75f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 125f32, "x of node {:?}. Expected {}. Actual {}", node1, 125f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 75f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 125f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 125f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_cross.rs b/tests/generated/flex/percentage_flex_basis_cross.rs index be57125e0..d1c275226 100644 --- a/tests/generated/flex/percentage_flex_basis_cross.rs +++ b/tests/generated/flex/percentage_flex_basis_cross.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_cross__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), ..Default::default() @@ -13,6 +14,7 @@ fn percentage_flex_basis_cross__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.25f32), ..Default::default() @@ -22,6 +24,10 @@ fn percentage_flex_basis_cross__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -35,24 +41,137 @@ fn percentage_flex_basis_cross__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node0, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 250f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node1, 250f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +183,7 @@ fn percentage_flex_basis_cross__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.5f32), ..Default::default() @@ -72,6 +192,7 @@ fn percentage_flex_basis_cross__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.25f32), ..Default::default() @@ -82,6 +203,10 @@ fn percentage_flex_basis_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -95,22 +220,135 @@ fn percentage_flex_basis_cross__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node0, 250f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 250f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 250f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node1, 250f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 150f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 150f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_cross_max_height.rs b/tests/generated/flex/percentage_flex_basis_cross_max_height.rs index 5e022ab2f..46c2476f9 100644 --- a/tests/generated/flex/percentage_flex_basis_cross_max_height.rs +++ b/tests/generated/flex/percentage_flex_basis_cross_max_height.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_cross_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_cross_max_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, @@ -24,6 +26,10 @@ fn percentage_flex_basis_cross_max_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -37,24 +43,131 @@ fn percentage_flex_basis_cross_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 240f32, "y of node {:?}. Expected {}. Actual {}", node1, 240f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 240f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +179,7 @@ fn percentage_flex_basis_cross_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, @@ -75,6 +189,7 @@ fn percentage_flex_basis_cross_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, @@ -86,6 +201,10 @@ fn percentage_flex_basis_cross_max_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -99,22 +218,129 @@ fn percentage_flex_basis_cross_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 240f32, "y of node {:?}. Expected {}. Actual {}", node1, 240f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 240f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_cross_max_width.rs b/tests/generated/flex/percentage_flex_basis_cross_max_width.rs index 8049c0887..8171b858a 100644 --- a/tests/generated/flex/percentage_flex_basis_cross_max_width.rs +++ b/tests/generated/flex/percentage_flex_basis_cross_max_width.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_cross_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_cross_max_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -24,6 +26,10 @@ fn percentage_flex_basis_cross_max_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -37,24 +43,137 @@ fn percentage_flex_basis_cross_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn percentage_flex_basis_cross_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -75,6 +195,7 @@ fn percentage_flex_basis_cross_max_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -86,6 +207,10 @@ fn percentage_flex_basis_cross_max_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -99,22 +224,135 @@ fn percentage_flex_basis_cross_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_cross_min_height.rs b/tests/generated/flex/percentage_flex_basis_cross_min_height.rs index 3c1c6f1a1..9e5b9a231 100644 --- a/tests/generated/flex/percentage_flex_basis_cross_min_height.rs +++ b/tests/generated/flex/percentage_flex_basis_cross_min_height.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_cross_min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn percentage_flex_basis_cross_min_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 2f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, ..Default::default() @@ -22,6 +24,10 @@ fn percentage_flex_basis_cross_min_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -35,24 +41,137 @@ fn percentage_flex_basis_cross_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node1, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 240f32, "y of node {:?}. Expected {}. Actual {}", node1, 240f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 240f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +183,7 @@ fn percentage_flex_basis_cross_min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, ..Default::default() @@ -72,6 +192,7 @@ fn percentage_flex_basis_cross_min_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 2f32, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, ..Default::default() @@ -82,6 +203,10 @@ fn percentage_flex_basis_cross_min_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -95,22 +220,135 @@ fn percentage_flex_basis_cross_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node1, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 240f32, "y of node {:?}. Expected {}. Actual {}", node1, 240f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 240f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_cross_min_width.rs b/tests/generated/flex/percentage_flex_basis_cross_min_width.rs index 486148809..7ba599a8e 100644 --- a/tests/generated/flex/percentage_flex_basis_cross_min_width.rs +++ b/tests/generated/flex/percentage_flex_basis_cross_min_width.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_cross_min_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_cross_min_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -24,6 +26,10 @@ fn percentage_flex_basis_cross_min_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -37,24 +43,137 @@ fn percentage_flex_basis_cross_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +185,7 @@ fn percentage_flex_basis_cross_min_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -75,6 +195,7 @@ fn percentage_flex_basis_cross_min_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -86,6 +207,10 @@ fn percentage_flex_basis_cross_min_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -99,22 +224,135 @@ fn percentage_flex_basis_cross_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_main_max_height.rs b/tests/generated/flex/percentage_flex_basis_main_max_height.rs index 500f6d407..e5a523de0 100644 --- a/tests/generated/flex/percentage_flex_basis_main_max_height.rs +++ b/tests/generated/flex/percentage_flex_basis_main_max_height.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_main_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_main_max_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, @@ -23,6 +25,10 @@ fn percentage_flex_basis_main_max_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -36,24 +42,131 @@ fn percentage_flex_basis_main_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node1, 148f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node1, 52f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +178,7 @@ fn percentage_flex_basis_main_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.6f32) }, @@ -74,6 +188,7 @@ fn percentage_flex_basis_main_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.2f32) }, @@ -84,6 +199,10 @@ fn percentage_flex_basis_main_max_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -97,22 +216,129 @@ fn percentage_flex_basis_main_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node1, 148f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node1, 52f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_main_max_width.rs b/tests/generated/flex/percentage_flex_basis_main_max_width.rs index 80fd22f3d..4f48ba8c8 100644 --- a/tests/generated/flex/percentage_flex_basis_main_max_width.rs +++ b/tests/generated/flex/percentage_flex_basis_main_max_width.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_main_max_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_main_max_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -23,6 +25,10 @@ fn percentage_flex_basis_main_max_width__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -36,24 +42,137 @@ fn percentage_flex_basis_main_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +184,7 @@ fn percentage_flex_basis_main_max_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -74,6 +194,7 @@ fn percentage_flex_basis_main_max_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -84,6 +205,10 @@ fn percentage_flex_basis_main_max_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -97,22 +222,135 @@ fn percentage_flex_basis_main_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_flex_basis_main_min_width.rs b/tests/generated/flex/percentage_flex_basis_main_min_width.rs index cdc7c787c..8603aeb62 100644 --- a/tests/generated/flex/percentage_flex_basis_main_min_width.rs +++ b/tests/generated/flex/percentage_flex_basis_main_min_width.rs @@ -6,6 +6,7 @@ fn percentage_flex_basis_main_min_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -14,6 +15,7 @@ fn percentage_flex_basis_main_min_width__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -23,6 +25,10 @@ fn percentage_flex_basis_main_min_width__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -36,24 +42,137 @@ fn percentage_flex_basis_main_min_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node1, 80f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +184,7 @@ fn percentage_flex_basis_main_min_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto() }, @@ -74,6 +194,7 @@ fn percentage_flex_basis_main_min_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -84,6 +205,10 @@ fn percentage_flex_basis_main_min_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -97,22 +222,135 @@ fn percentage_flex_basis_main_min_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node1, 80f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 400f32, + layout.size.height + ); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_main_max_height.rs b/tests/generated/flex/percentage_main_max_height.rs index db487ffa8..7ba60638d 100644 --- a/tests/generated/flex/percentage_main_max_height.rs +++ b/tests/generated/flex/percentage_main_max_height.rs @@ -5,10 +5,15 @@ fn percentage_main_max_height__border_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(15f32), ..Default::default() }) + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_basis: taffy::style::Dimension::from_length(15f32), + ..Default::default() + }) .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(48f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.33f32) }, ..Default::default() @@ -18,6 +23,10 @@ fn percentage_main_max_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(151f32) }, ..Default::default() @@ -29,6 +38,10 @@ fn percentage_main_max_height__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(71f32), height: auto() }, ..Default::default() }, @@ -39,30 +52,182 @@ fn percentage_main_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node, 71f32, size.width); - assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node, 151f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 151f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 151f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); - assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node0, 151f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 151f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 151f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node00, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node01, 48f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node01, 15f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 48f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -74,6 +239,7 @@ fn percentage_main_max_height__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(15f32), ..Default::default() }) @@ -81,6 +247,7 @@ fn percentage_main_max_height__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(48f32), max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.33f32) }, ..Default::default() @@ -91,6 +258,10 @@ fn percentage_main_max_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(151f32) }, ..Default::default() @@ -103,6 +274,10 @@ fn percentage_main_max_height__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(71f32), height: auto() }, ..Default::default() }, @@ -113,28 +288,180 @@ fn percentage_main_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node, 71f32, size.width); - assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node, 151f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 151f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 151f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); - assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node0, 151f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 71f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 71f32, layout.size.width); + } + if layout.size.height != 151f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 151f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node00, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node01, 48f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node01, 15f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 48f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs b/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs index a75c22588..e802688e8 100644 --- a/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs +++ b/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs @@ -6,6 +6,7 @@ fn percentage_margin_should_calculate_based_only_on_width__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn percentage_margin_should_calculate_based_only_on_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: percent(0.1f32), @@ -33,6 +38,10 @@ fn percentage_margin_should_calculate_based_only_on_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -46,24 +55,131 @@ fn percentage_margin_should_calculate_based_only_on_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +191,7 @@ fn percentage_margin_should_calculate_based_only_on_width__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -87,6 +204,10 @@ fn percentage_margin_should_calculate_based_only_on_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, margin: taffy::geometry::Rect { left: percent(0.1f32), @@ -104,6 +225,10 @@ fn percentage_margin_should_calculate_based_only_on_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -117,22 +242,129 @@ fn percentage_margin_should_calculate_based_only_on_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_moderate_complexity.rs b/tests/generated/flex/percentage_moderate_complexity.rs index 86f087e26..e1fb69823 100644 --- a/tests/generated/flex/percentage_moderate_complexity.rs +++ b/tests/generated/flex/percentage_moderate_complexity.rs @@ -7,6 +7,7 @@ fn percentage_moderate_complexity__border_box() { taffy.disable_rounding(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -28,6 +29,10 @@ fn percentage_moderate_complexity__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -51,6 +56,10 @@ fn percentage_moderate_complexity__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -67,54 +76,155 @@ fn percentage_moderate_complexity__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 200f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert!( - (size.height - 42.15625f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node, - 42.15625f32, - size.height - ); - assert!((location.x - 0f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert!((location.y - 0f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if (layout.size.width - 200f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if (layout.size.height - 42.15625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 42.15625f32, + layout.size.height + ); + } + if (layout.location.x - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if (layout.location.y - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 97f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 97f32, size.width); - assert!( - (size.height - 26.15625f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node0, - 26.15625f32, - size.height - ); - assert!((location.x - 8f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert!((location.y - 8f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if (layout.size.width - 97f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 97f32, layout.size.width); + } + if (layout.size.height - 26.15625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 26.15625f32, + layout.size.height + ); + } + if (layout.location.x - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if (layout.location.y - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert!( - (size.width - 38.40625f32).abs() < 0.1, - "width of node {:?}. Expected {}. Actual {}", - node00, - 38.40625f32, - size.width - ); - assert!((size.height - 6f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); - assert!( - (location.x - 10.078125f32).abs() < 0.1, - "x of node {:?}. Expected {}. Actual {}", - node00, - 10.078125f32, - location.x - ); - assert!( - (location.y - 10.078125f32).abs() < 0.1, - "y of node {:?}. Expected {}. Actual {}", - node00, - 10.078125f32, - location.y - ); + if (layout.size.width - 38.40625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.width), + 38.40625f32, + layout.size.width + ); + } + if (layout.size.height - 6f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 6f32, layout.size.height); + } + if (layout.location.x - 10.078125f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(location.x), + 10.078125f32, + layout.location.x + ); + } + if (layout.location.y - 10.078125f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(location.y), + 10.078125f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -127,6 +237,7 @@ fn percentage_moderate_complexity__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -149,6 +260,10 @@ fn percentage_moderate_complexity__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -173,6 +288,10 @@ fn percentage_moderate_complexity__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -189,28 +308,123 @@ fn percentage_moderate_complexity__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 206f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 206f32, size.width); - assert!((size.height - 44f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node, 44f32, size.height); - assert!((location.x - 0f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert!((location.y - 0f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if (layout.size.width - 206f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 206f32, layout.size.width); + } + if (layout.size.height - 44f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 44f32, layout.size.height); + } + if (layout.location.x - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if (layout.location.y - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 112f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 112f32, size.width); - assert!( - (size.height - 28f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node0, - 28f32, - size.height - ); - assert!((location.x - 8f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert!((location.y - 8f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if (layout.size.width - 112f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 112f32, layout.size.width); + } + if (layout.size.height - 28f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 28f32, layout.size.height); + } + if (layout.location.x - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if (layout.location.y - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 51f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node00, 51f32, size.width); - assert!((size.height - 6f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); - assert!((location.x - 11f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node00, 11f32, location.x); - assert!((location.y - 11f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); + if (layout.size.width - 51f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 51f32, layout.size.width); + } + if (layout.size.height - 6f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 6f32, layout.size.height); + } + if (layout.location.x - 11f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 11f32, layout.location.x); + } + if (layout.location.y - 11f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_moderate_complexity2.rs b/tests/generated/flex/percentage_moderate_complexity2.rs index 35d1184fe..bde6a608d 100644 --- a/tests/generated/flex/percentage_moderate_complexity2.rs +++ b/tests/generated/flex/percentage_moderate_complexity2.rs @@ -6,6 +6,7 @@ fn percentage_moderate_complexity2__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn percentage_moderate_complexity2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, padding: taffy::geometry::Rect { left: percent(0.1f32), @@ -33,6 +38,10 @@ fn percentage_moderate_complexity2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -46,24 +55,131 @@ fn percentage_moderate_complexity2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +191,7 @@ fn percentage_moderate_complexity2__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -87,6 +204,10 @@ fn percentage_moderate_complexity2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, padding: taffy::geometry::Rect { left: percent(0.1f32), @@ -104,6 +225,10 @@ fn percentage_moderate_complexity2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -117,22 +242,129 @@ fn percentage_moderate_complexity2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs index b006b208a..04f29f6dc 100644 --- a/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs +++ b/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -6,6 +6,7 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -26,6 +27,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -48,6 +53,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { @@ -73,6 +82,7 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -83,6 +93,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -96,36 +110,221 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__border_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node0, 48f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node00, 92f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node00, 25f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); + if layout.size.width != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 92f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 25f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node000, 36f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 6f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 142f32, "height of node {:?}. Expected {}. Actual {}", node1, 142f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 58f32, "y of node {:?}. Expected {}. Actual {}", node1, 58f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 142f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 142f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 58f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 58f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -137,6 +336,7 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -158,6 +358,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -181,6 +385,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_percent(0.1f32), min_size: taffy::geometry::Size { @@ -207,6 +415,7 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_percent(0.15f32), min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.2f32), height: auto() }, @@ -218,6 +427,10 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -231,34 +444,219 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values__content println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 103f32, "width of node {:?}. Expected {}. Actual {}", node00, 103f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node00, 26f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); + if layout.size.width != 103f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 103f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 26f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node000, 48f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 6f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 137f32, "height of node {:?}. Expected {}. Actual {}", node1, 137f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node1, 63f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 137f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 137f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 63f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs b/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs index cad70347c..3534d5edf 100644 --- a/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs +++ b/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs @@ -6,6 +6,7 @@ fn percentage_padding_should_calculate_based_only_on_width__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -17,6 +18,10 @@ fn percentage_padding_should_calculate_based_only_on_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, padding: taffy::geometry::Rect { left: percent(0.1f32), @@ -33,6 +38,10 @@ fn percentage_padding_should_calculate_based_only_on_width__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -46,24 +55,137 @@ fn percentage_padding_should_calculate_based_only_on_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +197,7 @@ fn percentage_padding_should_calculate_based_only_on_width__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -87,6 +210,10 @@ fn percentage_padding_should_calculate_based_only_on_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, padding: taffy::geometry::Rect { left: percent(0.1f32), @@ -104,6 +231,10 @@ fn percentage_padding_should_calculate_based_only_on_width__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(100f32), @@ -117,22 +248,135 @@ fn percentage_padding_should_calculate_based_only_on_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_position_bottom_right.rs b/tests/generated/flex/percentage_position_bottom_right.rs index 4e053749c..ed6ba3aee 100644 --- a/tests/generated/flex/percentage_position_bottom_right.rs +++ b/tests/generated/flex/percentage_position_bottom_right.rs @@ -6,6 +6,7 @@ fn percentage_position_bottom_right__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.55f32), height: taffy::style::Dimension::from_percent(0.15f32), @@ -17,6 +18,10 @@ fn percentage_position_bottom_right__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -30,18 +35,86 @@ fn percentage_position_bottom_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 275f32, "width of node {:?}. Expected {}. Actual {}", node0, 275f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); - assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node0, -50f32, location.y); + if layout.size.width != 275f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 275f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != -100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -100f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn percentage_position_bottom_right__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.55f32), height: taffy::style::Dimension::from_percent(0.15f32), @@ -65,6 +139,10 @@ fn percentage_position_bottom_right__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -78,16 +156,84 @@ fn percentage_position_bottom_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 275f32, "width of node {:?}. Expected {}. Actual {}", node0, 275f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); - assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); - assert_eq!(location.y, -50f32, "y of node {:?}. Expected {}. Actual {}", node0, -50f32, location.y); + if layout.size.width != 275f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 275f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != -100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -100f32, layout.location.x); + } + if layout.location.y != -50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_position_left_top.rs b/tests/generated/flex/percentage_position_left_top.rs index 487e420dd..e6bae1eff 100644 --- a/tests/generated/flex/percentage_position_left_top.rs +++ b/tests/generated/flex/percentage_position_left_top.rs @@ -6,6 +6,7 @@ fn percentage_position_left_top__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: taffy::style::Dimension::from_percent(0.55f32), @@ -17,6 +18,10 @@ fn percentage_position_left_top__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(400f32), @@ -30,18 +35,92 @@ fn percentage_position_left_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 220f32, "height of node {:?}. Expected {}. Actual {}", node0, 220f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 220f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 220f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +132,7 @@ fn percentage_position_left_top__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: taffy::style::Dimension::from_percent(0.55f32), @@ -65,6 +145,10 @@ fn percentage_position_left_top__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(400f32), @@ -78,16 +162,90 @@ fn percentage_position_left_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 220f32, "height of node {:?}. Expected {}. Actual {}", node0, 220f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 220f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 220f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs b/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs index 5a03b8c10..a61b2ffd1 100644 --- a/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs +++ b/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs @@ -6,6 +6,7 @@ fn percentage_size_based_on_parent_inner_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -17,6 +18,10 @@ fn percentage_size_based_on_parent_inner_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -36,18 +41,92 @@ fn percentage_size_based_on_parent_inner_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node0, 180f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +138,7 @@ fn percentage_size_based_on_parent_inner_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -71,6 +151,10 @@ fn percentage_size_based_on_parent_inner_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -90,16 +174,90 @@ fn percentage_size_based_on_parent_inner_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 440f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 440f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_size_of_flex_basis.rs b/tests/generated/flex/percentage_size_of_flex_basis.rs index 42a19b9fd..5fa840e37 100644 --- a/tests/generated/flex/percentage_size_of_flex_basis.rs +++ b/tests/generated/flex/percentage_size_of_flex_basis.rs @@ -6,6 +6,7 @@ fn percentage_size_of_flex_basis__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(100f32), @@ -15,13 +16,24 @@ fn percentage_size_of_flex_basis__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + flex_basis: taffy::style::Dimension::from_length(50f32), + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -32,24 +44,137 @@ fn percentage_size_of_flex_basis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +186,7 @@ fn percentage_size_of_flex_basis__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_length(100f32), @@ -72,6 +198,10 @@ fn percentage_size_of_flex_basis__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(50f32), ..Default::default() }, @@ -82,6 +212,10 @@ fn percentage_size_of_flex_basis__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -92,22 +226,135 @@ fn percentage_size_of_flex_basis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs b/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs index 3b19bfcd4..ec16173a7 100644 --- a/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs +++ b/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs @@ -4,10 +4,19 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1.2f32), height: auto() }, ..Default::default() }, @@ -17,6 +26,10 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -30,24 +43,137 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -57,12 +183,20 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1.2f32), height: auto() }, ..Default::default() }, @@ -73,6 +207,10 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -86,22 +224,135 @@ fn percentage_sizes_should_not_prevent_flex_shrinking__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_width_height.rs b/tests/generated/flex/percentage_width_height.rs index e8bd1f267..da560f911 100644 --- a/tests/generated/flex/percentage_width_height.rs +++ b/tests/generated/flex/percentage_width_height.rs @@ -6,6 +6,7 @@ fn percentage_width_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.3f32), height: taffy::style::Dimension::from_percent(0.3f32), @@ -16,6 +17,10 @@ fn percentage_width_height__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -29,18 +34,92 @@ fn percentage_width_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,6 +131,7 @@ fn percentage_width_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.3f32), height: taffy::style::Dimension::from_percent(0.3f32), @@ -63,6 +143,10 @@ fn percentage_width_height__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(400f32), @@ -76,16 +160,90 @@ fn percentage_width_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 400f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/percentage_width_height_undefined_parent_size.rs b/tests/generated/flex/percentage_width_height_undefined_parent_size.rs index 22d388dd9..d6e24fea9 100644 --- a/tests/generated/flex/percentage_width_height_undefined_parent_size.rs +++ b/tests/generated/flex/percentage_width_height_undefined_parent_size.rs @@ -6,6 +6,7 @@ fn percentage_width_height_undefined_parent_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -15,7 +16,14 @@ fn percentage_width_height_undefined_parent_size__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -23,18 +31,86 @@ fn percentage_width_height_undefined_parent_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +122,7 @@ fn percentage_width_height_undefined_parent_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: taffy::style::Dimension::from_percent(0.5f32), @@ -58,6 +135,10 @@ fn percentage_width_height_undefined_parent_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -67,16 +148,84 @@ fn percentage_width_height_undefined_parent_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs b/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs index 051d89bc7..5ad509e70 100644 --- a/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs +++ b/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs @@ -6,6 +6,7 @@ fn position_root_with_rtl_should_position_withoutdirection__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -14,23 +15,102 @@ fn position_root_with_rtl_should_position_withoutdirection__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 72f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0, 52f32, size.height); - assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0, 72f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 72f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -42,6 +122,7 @@ fn position_root_with_rtl_should_position_withoutdirection__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(52f32), height: taffy::style::Dimension::from_length(52f32), @@ -52,7 +133,14 @@ fn position_root_with_rtl_should_position_withoutdirection__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -60,16 +148,84 @@ fn position_root_with_rtl_should_position_withoutdirection__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 72f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); - assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0, 52f32, size.height); - assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0, 72f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 52f32, layout.size.height); + } + if layout.location.x != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 72f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/relative_position_should_not_nudge_siblings.rs b/tests/generated/flex/relative_position_should_not_nudge_siblings.rs index e05295e99..238db5a98 100644 --- a/tests/generated/flex/relative_position_should_not_nudge_siblings.rs +++ b/tests/generated/flex/relative_position_should_not_nudge_siblings.rs @@ -6,6 +6,7 @@ fn relative_position_should_not_nudge_siblings__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(15f32), bottom: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn relative_position_should_not_nudge_siblings__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(15f32), bottom: auto() }, ..Default::default() @@ -22,6 +24,10 @@ fn relative_position_should_not_nudge_siblings__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -35,24 +41,125 @@ fn relative_position_should_not_nudge_siblings__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node1, 25f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +171,7 @@ fn relative_position_should_not_nudge_siblings__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(15f32), bottom: auto() }, ..Default::default() @@ -72,6 +180,7 @@ fn relative_position_should_not_nudge_siblings__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(15f32), bottom: auto() }, ..Default::default() @@ -82,6 +191,10 @@ fn relative_position_should_not_nudge_siblings__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -95,22 +208,123 @@ fn relative_position_should_not_nudge_siblings__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node1, 25f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.rs index 6bd03fa9f..001d4d715 100644 --- a/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.rs +++ b/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -4,14 +4,48 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(113f32), height: taffy::style::Dimension::from_length(100f32), @@ -25,42 +59,272 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 113f32, "width of node {:?}. Expected {}. Actual {}", node, 113f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 113f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node0, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1, 22f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 23f32, "x of node {:?}. Expected {}. Actual {}", node1, 23f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 23f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node2, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node2, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node3, 22f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node3, 68f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 68f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node4, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node4, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,6 +336,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -79,6 +344,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -86,6 +352,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -93,6 +360,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -100,6 +368,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -108,6 +377,10 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(113f32), height: taffy::style::Dimension::from_length(100f32), @@ -121,40 +394,270 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 113f32, "width of node {:?}. Expected {}. Actual {}", node, 113f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 113f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node0, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1, 22f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 23f32, "x of node {:?}. Expected {}. Actual {}", node1, 23f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 23f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node2, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node2, 45f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 45f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node3, 22f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node3, 68f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 68f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node4, 23f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node4, 90f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 23f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 23f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.rs b/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.rs index 18c0de178..6ea06d67e 100644 --- a/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.rs +++ b/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -4,12 +4,34 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -23,30 +45,182 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node1, 34f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node2, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +232,7 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -65,6 +240,7 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -72,6 +248,7 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -80,6 +257,10 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -93,28 +274,180 @@ fn rounding_flex_basis_flex_grow_row_width_of_100__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node1, 34f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node2, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs b/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs index 9077afffd..af1e97779 100644 --- a/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs +++ b/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs @@ -6,20 +6,33 @@ fn rounding_flex_basis_flex_shrink_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(25f32), ..Default::default() }) + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_basis: taffy::style::Dimension::from_length(25f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::from_length(25f32), ..Default::default() }) + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_basis: taffy::style::Dimension::from_length(25f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(101f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,30 +46,182 @@ fn rounding_flex_basis_flex_shrink_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node, 101f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 101f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node1, 17f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 84f32, "x of node {:?}. Expected {}. Actual {}", node2, 84f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 84f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 84f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +233,7 @@ fn rounding_flex_basis_flex_shrink_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_length(100f32), ..Default::default() @@ -76,6 +242,7 @@ fn rounding_flex_basis_flex_shrink_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(25f32), ..Default::default() }) @@ -83,6 +250,7 @@ fn rounding_flex_basis_flex_shrink_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_basis: taffy::style::Dimension::from_length(25f32), ..Default::default() }) @@ -91,6 +259,10 @@ fn rounding_flex_basis_flex_shrink_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(101f32), height: taffy::style::Dimension::from_length(100f32), @@ -104,28 +276,180 @@ fn rounding_flex_basis_flex_shrink_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node, 101f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 101f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node1, 17f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 84f32, "x of node {:?}. Expected {}. Actual {}", node2, 84f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 17f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 84f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 84f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_flex_basis_overrides_main_size.rs b/tests/generated/flex/rounding_flex_basis_overrides_main_size.rs index e5e735e30..4c527f375 100644 --- a/tests/generated/flex/rounding_flex_basis_overrides_main_size.rs +++ b/tests/generated/flex/rounding_flex_basis_overrides_main_size.rs @@ -6,6 +6,7 @@ fn rounding_flex_basis_overrides_main_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -14,6 +15,7 @@ fn rounding_flex_basis_overrides_main_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_flex_basis_overrides_main_size__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_flex_basis_overrides_main_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113f32), @@ -43,30 +50,164 @@ fn rounding_flex_basis_overrides_main_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_flex_basis_overrides_main_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -87,6 +229,7 @@ fn rounding_flex_basis_overrides_main_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_flex_basis_overrides_main_size__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_flex_basis_overrides_main_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113f32), @@ -118,28 +266,162 @@ fn rounding_flex_basis_overrides_main_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_1.rs b/tests/generated/flex/rounding_fractial_input_1.rs index a5b65811d..aa2723698 100644 --- a/tests/generated/flex/rounding_fractial_input_1.rs +++ b/tests/generated/flex/rounding_fractial_input_1.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_1__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -14,6 +15,7 @@ fn rounding_fractial_input_1__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_fractial_input_1__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_fractial_input_1__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -43,30 +50,164 @@ fn rounding_fractial_input_1__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_fractial_input_1__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -87,6 +229,7 @@ fn rounding_fractial_input_1__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_fractial_input_1__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_fractial_input_1__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -118,28 +266,162 @@ fn rounding_fractial_input_1__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_2.rs b/tests/generated/flex/rounding_fractial_input_2.rs index b5669f628..f52fc846b 100644 --- a/tests/generated/flex/rounding_fractial_input_2.rs +++ b/tests/generated/flex/rounding_fractial_input_2.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_2__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -14,6 +15,7 @@ fn rounding_fractial_input_2__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_fractial_input_2__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_fractial_input_2__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.6f32), @@ -43,30 +50,164 @@ fn rounding_fractial_input_2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 114f32, "height of node {:?}. Expected {}. Actual {}", node, 114f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 114f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 114f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node0, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node2, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_fractial_input_2__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -87,6 +229,7 @@ fn rounding_fractial_input_2__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_fractial_input_2__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_fractial_input_2__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.6f32), @@ -118,28 +266,162 @@ fn rounding_fractial_input_2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 114f32, "height of node {:?}. Expected {}. Actual {}", node, 114f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 114f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 114f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node0, 65f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 65f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node2, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_3.rs b/tests/generated/flex/rounding_fractial_input_3.rs index a23f443ef..ca0b57105 100644 --- a/tests/generated/flex/rounding_fractial_input_3.rs +++ b/tests/generated/flex/rounding_fractial_input_3.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_3__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -14,6 +15,7 @@ fn rounding_fractial_input_3__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_fractial_input_3__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_fractial_input_3__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -43,30 +50,164 @@ fn rounding_fractial_input_3__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_fractial_input_3__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -87,6 +229,7 @@ fn rounding_fractial_input_3__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_fractial_input_3__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_fractial_input_3__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -118,28 +266,162 @@ fn rounding_fractial_input_3__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_4.rs b/tests/generated/flex/rounding_fractial_input_4.rs index 01f80556a..09c1f0cc7 100644 --- a/tests/generated/flex/rounding_fractial_input_4.rs +++ b/tests/generated/flex/rounding_fractial_input_4.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_4__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -14,6 +15,7 @@ fn rounding_fractial_input_4__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_fractial_input_4__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_fractial_input_4__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -43,30 +50,164 @@ fn rounding_fractial_input_4__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_fractial_input_4__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(50f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, @@ -87,6 +229,7 @@ fn rounding_fractial_input_4__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_fractial_input_4__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_fractial_input_4__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -118,28 +266,162 @@ fn rounding_fractial_input_4__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 64f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_5.rs b/tests/generated/flex/rounding_fractial_input_5.rs index 8ec78b7ef..cce21fba4 100644 --- a/tests/generated/flex/rounding_fractial_input_5.rs +++ b/tests/generated/flex/rounding_fractial_input_5.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_5__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100.3f32), height: taffy::style::Dimension::from_length(100.3f32), @@ -15,6 +16,7 @@ fn rounding_fractial_input_5__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100.3f32), height: taffy::style::Dimension::from_length(100.3f32), @@ -25,6 +27,10 @@ fn rounding_fractial_input_5__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(963.333f32), @@ -39,24 +45,137 @@ fn rounding_fractial_input_5__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 963f32, "width of node {:?}. Expected {}. Actual {}", node, 963f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 963f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 963f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node0, 101f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0, 381f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 101f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 381f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 381f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1, 482f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 482f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 482f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -68,6 +187,7 @@ fn rounding_fractial_input_5__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100.3f32), height: taffy::style::Dimension::from_length(100.3f32), @@ -78,6 +198,7 @@ fn rounding_fractial_input_5__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100.3f32), height: taffy::style::Dimension::from_length(100.3f32), @@ -89,6 +210,10 @@ fn rounding_fractial_input_5__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(963.333f32), @@ -103,22 +228,135 @@ fn rounding_fractial_input_5__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 963f32, "width of node {:?}. Expected {}. Actual {}", node, 963f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 963f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 963f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node0, 101f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0, 381f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 101f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 101f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 381f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 381f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1, 482f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 482f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 482f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_6.rs b/tests/generated/flex/rounding_fractial_input_6.rs index 01a5f8dda..a247471cf 100644 --- a/tests/generated/flex/rounding_fractial_input_6.rs +++ b/tests/generated/flex/rounding_fractial_input_6.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_6__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn rounding_fractial_input_6__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn rounding_fractial_input_6__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -34,6 +40,7 @@ fn rounding_fractial_input_6__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -43,6 +50,7 @@ fn rounding_fractial_input_6__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -54,6 +62,10 @@ fn rounding_fractial_input_6__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -63,6 +75,10 @@ fn rounding_fractial_input_6__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(7f32), height: auto() }, ..Default::default() }, @@ -73,48 +89,305 @@ fn rounding_fractial_input_6__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 7f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node0, 4f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 3f32, "width of node {:?}. Expected {}. Actual {}", node1, 3f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node1, 4f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 3f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node11, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11, 10f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -126,6 +399,7 @@ fn rounding_fractial_input_6__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -136,6 +410,7 @@ fn rounding_fractial_input_6__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -148,6 +423,10 @@ fn rounding_fractial_input_6__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -157,6 +436,7 @@ fn rounding_fractial_input_6__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -167,6 +447,7 @@ fn rounding_fractial_input_6__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(10f32), @@ -179,6 +460,10 @@ fn rounding_fractial_input_6__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -189,6 +474,10 @@ fn rounding_fractial_input_6__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(7f32), height: auto() }, ..Default::default() }, @@ -199,46 +488,303 @@ fn rounding_fractial_input_6__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 7f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node0, 4f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 3f32, "width of node {:?}. Expected {}. Actual {}", node1, 3f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node1, 4f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 3f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node11, 2f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11, 10f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_fractial_input_7.rs b/tests/generated/flex/rounding_fractial_input_7.rs index 15c55c75c..bfa05f561 100644 --- a/tests/generated/flex/rounding_fractial_input_7.rs +++ b/tests/generated/flex/rounding_fractial_input_7.rs @@ -6,6 +6,7 @@ fn rounding_fractial_input_7__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -26,6 +28,10 @@ fn rounding_fractial_input_7__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -34,6 +40,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -43,6 +50,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node11 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -54,6 +62,10 @@ fn rounding_fractial_input_7__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -62,6 +74,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -71,6 +84,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node21 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -82,6 +96,10 @@ fn rounding_fractial_input_7__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -90,6 +108,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node30 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -99,6 +118,7 @@ fn rounding_fractial_input_7__border_box() { .unwrap(); let node31 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -110,6 +130,10 @@ fn rounding_fractial_input_7__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -119,6 +143,10 @@ fn rounding_fractial_input_7__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(7f32), height: auto() }, ..Default::default() }, @@ -129,84 +157,563 @@ fn rounding_fractial_input_7__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 7f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node00, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node01, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node1, 2f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node10, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node11, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node2, 1f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node2, 4f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node20, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node21, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node21, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node21, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node21, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node3, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node30).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node30, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node30, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node31).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node31, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node31, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node31, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node31, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -218,6 +725,7 @@ fn rounding_fractial_input_7__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -228,6 +736,7 @@ fn rounding_fractial_input_7__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -240,6 +749,10 @@ fn rounding_fractial_input_7__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -249,6 +762,7 @@ fn rounding_fractial_input_7__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -259,6 +773,7 @@ fn rounding_fractial_input_7__content_box() { let node11 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -271,6 +786,10 @@ fn rounding_fractial_input_7__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -280,6 +799,7 @@ fn rounding_fractial_input_7__content_box() { let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -290,6 +810,7 @@ fn rounding_fractial_input_7__content_box() { let node21 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -302,6 +823,10 @@ fn rounding_fractial_input_7__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -311,6 +836,7 @@ fn rounding_fractial_input_7__content_box() { let node30 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -321,6 +847,7 @@ fn rounding_fractial_input_7__content_box() { let node31 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(1f32), height: taffy::style::Dimension::from_length(10f32), @@ -333,6 +860,10 @@ fn rounding_fractial_input_7__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.25f32), height: auto() }, ..Default::default() }, @@ -343,6 +874,10 @@ fn rounding_fractial_input_7__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(7f32), height: auto() }, ..Default::default() }, @@ -353,82 +888,561 @@ fn rounding_fractial_input_7__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 7f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node00, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node01, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node1, 2f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 2f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node10, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node11, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node2, 1f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node2, 4f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node20, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node21).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node21, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node21, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node21, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node21, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node21, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node21, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node3, 2f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node30).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node30, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node30, 0f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node30, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node30, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node31).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node31, 1f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node31, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node31, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node31, 10f32, location.y); + if layout.size.width != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(size.width), 1f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node31, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node31, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_inner_node_controversy_combined.rs b/tests/generated/flex/rounding_inner_node_controversy_combined.rs index 582ba3aec..0ca2c0322 100644 --- a/tests/generated/flex/rounding_inner_node_controversy_combined.rs +++ b/tests/generated/flex/rounding_inner_node_controversy_combined.rs @@ -6,6 +6,7 @@ fn rounding_inner_node_controversy_combined__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn rounding_inner_node_controversy_combined__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -20,6 +22,7 @@ fn rounding_inner_node_controversy_combined__border_box() { .unwrap(); let node110 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -29,6 +32,10 @@ fn rounding_inner_node_controversy_combined__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -38,6 +45,7 @@ fn rounding_inner_node_controversy_combined__border_box() { .unwrap(); let node12 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -47,6 +55,10 @@ fn rounding_inner_node_controversy_combined__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -56,6 +68,7 @@ fn rounding_inner_node_controversy_combined__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -64,6 +77,10 @@ fn rounding_inner_node_controversy_combined__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(640f32), height: taffy::style::Dimension::from_length(320f32), @@ -77,54 +94,368 @@ fn rounding_inner_node_controversy_combined__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node, 640f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 640f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 640f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0, 213f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 213f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1, 214f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1, 320f32, size.height); - assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1, 213f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 213f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10, 214f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11, 214f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11, 107f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 107f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node110).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110, 214f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(size.width), + 214f32, + layout.size.width + ); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node110, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node110, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12, 214f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12, 213f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 213f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2, 213f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2, 320f32, size.height); - assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2, 427f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 213f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 427f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 427f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -136,6 +467,7 @@ fn rounding_inner_node_controversy_combined__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -144,6 +476,7 @@ fn rounding_inner_node_controversy_combined__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -152,6 +485,7 @@ fn rounding_inner_node_controversy_combined__content_box() { let node110 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -162,6 +496,10 @@ fn rounding_inner_node_controversy_combined__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -172,6 +510,7 @@ fn rounding_inner_node_controversy_combined__content_box() { let node12 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: auto() }, ..Default::default() @@ -182,6 +521,10 @@ fn rounding_inner_node_controversy_combined__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -192,6 +535,7 @@ fn rounding_inner_node_controversy_combined__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() @@ -201,6 +545,10 @@ fn rounding_inner_node_controversy_combined__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(640f32), height: taffy::style::Dimension::from_length(320f32), @@ -214,52 +562,366 @@ fn rounding_inner_node_controversy_combined__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node, 640f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 640f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 640f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0, 213f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 213f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1, 214f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1, 320f32, size.height); - assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1, 213f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 213f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10, 214f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11, 214f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); - assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11, 107f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 107f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node110).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110, 214f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110, 0f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(size.width), + 214f32, + layout.size.width + ); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node110, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node110, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node110, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12, 214f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12, 213f32, location.y); + if layout.size.width != 214f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 214f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 213f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2, 213f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2, 320f32, size.height); - assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2, 427f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 213f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 427f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 427f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs b/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs index da66e0400..2eaca5583 100644 --- a/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs +++ b/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs @@ -6,6 +6,7 @@ fn rounding_inner_node_controversy_horizontal__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -13,6 +14,7 @@ fn rounding_inner_node_controversy_horizontal__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -22,6 +24,10 @@ fn rounding_inner_node_controversy_horizontal__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -31,6 +37,7 @@ fn rounding_inner_node_controversy_horizontal__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -39,6 +46,10 @@ fn rounding_inner_node_controversy_horizontal__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, ..Default::default() }, @@ -49,36 +60,209 @@ fn rounding_inner_node_controversy_horizontal__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0, 107f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 107f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1, 106f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1, 107f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 106f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 106f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 107f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10, 106f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 106f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 106f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2, 107f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2, 213f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 107f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 213f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +274,7 @@ fn rounding_inner_node_controversy_horizontal__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -98,6 +283,7 @@ fn rounding_inner_node_controversy_horizontal__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -108,6 +294,10 @@ fn rounding_inner_node_controversy_horizontal__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -118,6 +308,7 @@ fn rounding_inner_node_controversy_horizontal__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -127,6 +318,10 @@ fn rounding_inner_node_controversy_horizontal__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, ..Default::default() }, @@ -137,34 +332,207 @@ fn rounding_inner_node_controversy_horizontal__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0, 107f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 107f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1, 106f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1, 107f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 106f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 106f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 107f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10, 106f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 106f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 106f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2, 107f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2, 213f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 107f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 213f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_inner_node_controversy_vertical.rs b/tests/generated/flex/rounding_inner_node_controversy_vertical.rs index 2f57440bf..9b87b99c5 100644 --- a/tests/generated/flex/rounding_inner_node_controversy_vertical.rs +++ b/tests/generated/flex/rounding_inner_node_controversy_vertical.rs @@ -6,6 +6,7 @@ fn rounding_inner_node_controversy_vertical__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -13,6 +14,7 @@ fn rounding_inner_node_controversy_vertical__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -22,6 +24,10 @@ fn rounding_inner_node_controversy_vertical__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -31,6 +37,7 @@ fn rounding_inner_node_controversy_vertical__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -40,6 +47,10 @@ fn rounding_inner_node_controversy_vertical__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(320f32) }, ..Default::default() }, @@ -50,36 +61,227 @@ fn rounding_inner_node_controversy_vertical__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1, 107f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 107f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node2, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node2, 213f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 213f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +293,7 @@ fn rounding_inner_node_controversy_vertical__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -99,6 +302,7 @@ fn rounding_inner_node_controversy_vertical__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -109,6 +313,10 @@ fn rounding_inner_node_controversy_vertical__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -119,6 +327,7 @@ fn rounding_inner_node_controversy_vertical__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() @@ -129,6 +338,10 @@ fn rounding_inner_node_controversy_vertical__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(320f32) }, ..Default::default() }, @@ -139,34 +352,225 @@ fn rounding_inner_node_controversy_vertical__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 320f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1, 107f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 107f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 107f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); - assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10, 106f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 106f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 106f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node2, 107f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node2, 213f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 213f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 213f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_total_fractial.rs b/tests/generated/flex/rounding_total_fractial.rs index b0bc5ea32..9143d0e36 100644 --- a/tests/generated/flex/rounding_total_fractial.rs +++ b/tests/generated/flex/rounding_total_fractial.rs @@ -6,6 +6,7 @@ fn rounding_total_fractial__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::from_length(50.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20.3f32) }, @@ -14,6 +15,7 @@ fn rounding_total_fractial__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.6f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -21,6 +23,7 @@ fn rounding_total_fractial__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10.7f32) }, ..Default::default() @@ -30,6 +33,10 @@ fn rounding_total_fractial__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(87.4f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -43,30 +50,164 @@ fn rounding_total_fractial__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); - assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 59f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +219,7 @@ fn rounding_total_fractial__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::from_length(50.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20.3f32) }, @@ -87,6 +229,7 @@ fn rounding_total_fractial__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.6f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -95,6 +238,7 @@ fn rounding_total_fractial__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10.7f32) }, ..Default::default() @@ -105,6 +249,10 @@ fn rounding_total_fractial__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(87.4f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -118,28 +266,162 @@ fn rounding_total_fractial__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); - assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 59f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/rounding_total_fractial_nested.rs b/tests/generated/flex/rounding_total_fractial_nested.rs index 4d956085d..63d89bd3f 100644 --- a/tests/generated/flex/rounding_total_fractial_nested.rs +++ b/tests/generated/flex/rounding_total_fractial_nested.rs @@ -6,6 +6,7 @@ fn rounding_total_fractial_nested__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(9.9f32) }, @@ -15,6 +16,7 @@ fn rounding_total_fractial_nested__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_length(0.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1.1f32) }, @@ -26,6 +28,10 @@ fn rounding_total_fractial_nested__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::from_length(50.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20.3f32) }, @@ -36,6 +42,7 @@ fn rounding_total_fractial_nested__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.6f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -43,6 +50,7 @@ fn rounding_total_fractial_nested__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10.7f32) }, ..Default::default() @@ -52,6 +60,10 @@ fn rounding_total_fractial_nested__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(87.4f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -65,42 +77,254 @@ fn rounding_total_fractial_nested__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); - assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 13f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 13f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node00, 87f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node00, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, -13f32, "y of node {:?}. Expected {}. Actual {}", node00, -13f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 12f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node01, 87f32, size.width); - assert_eq!(size.height, 47f32, "height of node {:?}. Expected {}. Actual {}", node01, 47f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node01, 25f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 47f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 47f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 59f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +336,7 @@ fn rounding_total_fractial_nested__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(9.9f32) }, @@ -122,6 +347,7 @@ fn rounding_total_fractial_nested__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 4f32, flex_basis: taffy::style::Dimension::from_length(0.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(1.1f32) }, @@ -134,6 +360,10 @@ fn rounding_total_fractial_nested__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::from_length(50.3f32), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20.3f32) }, @@ -145,6 +375,7 @@ fn rounding_total_fractial_nested__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.6f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() @@ -153,6 +384,7 @@ fn rounding_total_fractial_nested__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1.1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10.7f32) }, ..Default::default() @@ -163,6 +395,10 @@ fn rounding_total_fractial_nested__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(87.4f32), height: taffy::style::Dimension::from_length(113.4f32), @@ -176,40 +412,252 @@ fn rounding_total_fractial_nested__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); - assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 113f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); - assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 13f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 13f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node00, 87f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node00, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, -13f32, "y of node {:?}. Expected {}. Actual {}", node00, -13f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 12f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != -13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node01, 87f32, size.width); - assert_eq!(size.height, 47f32, "height of node {:?}. Expected {}. Actual {}", node01, 47f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node01, 25f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 47f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 47f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 59f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2, 89f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 89f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/scroll_size.rs b/tests/generated/flex/scroll_size.rs index 9a0b62725..39f31c685 100644 --- a/tests/generated/flex/scroll_size.rs +++ b/tests/generated/flex/scroll_size.rs @@ -6,6 +6,7 @@ fn scroll_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -37,36 +38,92 @@ fn scroll_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 65f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 65f32, - layout.scroll_height() - ); + if layout.scroll_height() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 65f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +135,7 @@ fn scroll_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -110,34 +168,90 @@ fn scroll_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 65f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 65f32, - layout.scroll_height() - ); + if layout.scroll_height() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 65f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/simple_child.rs b/tests/generated/flex/simple_child.rs index 40100109a..a41423f0f 100644 --- a/tests/generated/flex/simple_child.rs +++ b/tests/generated/flex/simple_child.rs @@ -6,6 +6,7 @@ fn simple_child__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn simple_child__border_box() { let node00 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -27,6 +32,7 @@ fn simple_child__border_box() { .unwrap(); let node010 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -37,6 +43,7 @@ fn simple_child__border_box() { .unwrap(); let node011 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -45,10 +52,25 @@ fn simple_child__border_box() { ..Default::default() }) .unwrap(); - let node01 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node010, node011]).unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node010, node011], + ) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -61,6 +83,10 @@ fn simple_child__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,48 +100,317 @@ fn simple_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node010, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node010, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node010, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node011, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node011, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node011, 10f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node011, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -127,6 +422,7 @@ fn simple_child__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +434,10 @@ fn simple_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -150,6 +450,7 @@ fn simple_child__content_box() { let node010 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -161,6 +462,7 @@ fn simple_child__content_box() { let node011 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -171,7 +473,14 @@ fn simple_child__content_box() { .unwrap(); let node01 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node010, node011], ) .unwrap(); @@ -179,6 +488,10 @@ fn simple_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -192,6 +505,10 @@ fn simple_child__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -205,46 +522,315 @@ fn simple_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node010, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node010, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node010, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node011).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node011, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node011, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node011, 10f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node011, 45f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node011, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node011, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/single_flex_child_after_absolute_child.rs b/tests/generated/flex/single_flex_child_after_absolute_child.rs index 04a385ee1..403abb2a4 100644 --- a/tests/generated/flex/single_flex_child_after_absolute_child.rs +++ b/tests/generated/flex/single_flex_child_after_absolute_child.rs @@ -7,6 +7,7 @@ fn single_flex_child_after_absolute_child__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -14,10 +15,17 @@ fn single_flex_child_after_absolute_child__border_box() { ..Default::default() }) .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(174f32), ..Default::default() @@ -27,6 +35,10 @@ fn single_flex_child_after_absolute_child__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(428f32), height: taffy::style::Dimension::from_length(845f32), @@ -40,30 +52,182 @@ fn single_flex_child_after_absolute_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node, 428f32, size.width); - assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node, 845f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 845f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 845f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node0, 428f32, size.width); - assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node0, 845f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 845f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 845f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node1, 428f32, size.width); - assert_eq!(size.height, 671f32, "height of node {:?}. Expected {}. Actual {}", node1, 671f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 671f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 671f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node2, 428f32, size.width); - assert_eq!(size.height, 174f32, "height of node {:?}. Expected {}. Actual {}", node2, 174f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 671f32, "y of node {:?}. Expected {}. Actual {}", node2, 671f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 174f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 174f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 671f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 671f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -76,6 +240,7 @@ fn single_flex_child_after_absolute_child__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -86,6 +251,7 @@ fn single_flex_child_after_absolute_child__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() @@ -94,6 +260,7 @@ fn single_flex_child_after_absolute_child__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, flex_basis: taffy::style::Dimension::from_length(174f32), ..Default::default() @@ -104,6 +271,10 @@ fn single_flex_child_after_absolute_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(428f32), height: taffy::style::Dimension::from_length(845f32), @@ -117,28 +288,180 @@ fn single_flex_child_after_absolute_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node, 428f32, size.width); - assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node, 845f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 845f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 845f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node0, 428f32, size.width); - assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node0, 845f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 845f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 845f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node1, 428f32, size.width); - assert_eq!(size.height, 671f32, "height of node {:?}. Expected {}. Actual {}", node1, 671f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 671f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 671f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node2, 428f32, size.width); - assert_eq!(size.height, 174f32, "height of node {:?}. Expected {}. Actual {}", node2, 174f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 671f32, "y of node {:?}. Expected {}. Actual {}", node2, 671f32, location.y); + if layout.size.width != 428f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 428f32, layout.size.width); + } + if layout.size.height != 174f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 174f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 671f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 671f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/size_defined_by_child.rs b/tests/generated/flex/size_defined_by_child.rs index 3920a4695..97cfa562a 100644 --- a/tests/generated/flex/size_defined_by_child.rs +++ b/tests/generated/flex/size_defined_by_child.rs @@ -6,6 +6,7 @@ fn size_defined_by_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -13,23 +14,108 @@ fn size_defined_by_child__border_box() { ..Default::default() }) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -41,6 +127,7 @@ fn size_defined_by_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -50,7 +137,14 @@ fn size_defined_by_child__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -58,16 +152,90 @@ fn size_defined_by_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/size_defined_by_child_with_border.rs b/tests/generated/flex/size_defined_by_child_with_border.rs index 01e7fe45e..481b5fb3c 100644 --- a/tests/generated/flex/size_defined_by_child_with_border.rs +++ b/tests/generated/flex/size_defined_by_child_with_border.rs @@ -6,6 +6,7 @@ fn size_defined_by_child_with_border__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn size_defined_by_child_with_border__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -31,18 +36,86 @@ fn size_defined_by_child_with_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn size_defined_by_child_with_border__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -65,6 +139,10 @@ fn size_defined_by_child_with_border__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -80,16 +158,84 @@ fn size_defined_by_child_with_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/size_defined_by_child_with_padding.rs b/tests/generated/flex/size_defined_by_child_with_padding.rs index 4a7d5d63d..661a4fa5b 100644 --- a/tests/generated/flex/size_defined_by_child_with_padding.rs +++ b/tests/generated/flex/size_defined_by_child_with_padding.rs @@ -6,6 +6,7 @@ fn size_defined_by_child_with_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -16,6 +17,10 @@ fn size_defined_by_child_with_padding__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -31,18 +36,86 @@ fn size_defined_by_child_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn size_defined_by_child_with_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -65,6 +139,10 @@ fn size_defined_by_child_with_padding__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(10f32), right: length(10f32), @@ -80,16 +158,84 @@ fn size_defined_by_child_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/size_defined_by_grand_child.rs b/tests/generated/flex/size_defined_by_grand_child.rs index e32f4692b..49b32bdf7 100644 --- a/tests/generated/flex/size_defined_by_grand_child.rs +++ b/tests/generated/flex/size_defined_by_grand_child.rs @@ -6,6 +6,7 @@ fn size_defined_by_grand_child__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -13,30 +14,165 @@ fn size_defined_by_grand_child__border_box() { ..Default::default() }) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,6 +184,7 @@ fn size_defined_by_grand_child__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -57,13 +194,27 @@ fn size_defined_by_grand_child__content_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -71,22 +222,135 @@ fn size_defined_by_grand_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/taffy_issue_696.rs b/tests/generated/flex/taffy_issue_696.rs index 2de69fdae..bc5b706fd 100644 --- a/tests/generated/flex/taffy_issue_696.rs +++ b/tests/generated/flex/taffy_issue_696.rs @@ -7,6 +7,7 @@ fn taffy_issue_696__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -40,6 +41,10 @@ fn taffy_issue_696__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -50,42 +55,137 @@ fn taffy_issue_696__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 140f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 140f32, - layout.scroll_height() - ); + if layout.scroll_height() != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 140f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +198,7 @@ fn taffy_issue_696__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -133,6 +234,10 @@ fn taffy_issue_696__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -143,40 +248,135 @@ fn taffy_issue_696__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 100f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 100f32, - layout.scroll_height() - ); + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/taffy_issue_696_flex_basis_20.rs b/tests/generated/flex/taffy_issue_696_flex_basis_20.rs index 28d3cf338..aaf570e04 100644 --- a/tests/generated/flex/taffy_issue_696_flex_basis_20.rs +++ b/tests/generated/flex/taffy_issue_696_flex_basis_20.rs @@ -7,6 +7,7 @@ fn taffy_issue_696_flex_basis_20__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -40,6 +41,10 @@ fn taffy_issue_696_flex_basis_20__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -50,42 +55,137 @@ fn taffy_issue_696_flex_basis_20__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 140f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 140f32, - layout.scroll_height() - ); + if layout.scroll_height() != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 140f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +198,7 @@ fn taffy_issue_696_flex_basis_20__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -133,6 +234,10 @@ fn taffy_issue_696_flex_basis_20__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -143,40 +248,135 @@ fn taffy_issue_696_flex_basis_20__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 100f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 100f32, - layout.scroll_height() - ); + if layout.scroll_height() != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 100f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/taffy_issue_696_min_height.rs b/tests/generated/flex/taffy_issue_696_min_height.rs index 17a67ff39..2266c2dc3 100644 --- a/tests/generated/flex/taffy_issue_696_min_height.rs +++ b/tests/generated/flex/taffy_issue_696_min_height.rs @@ -7,6 +7,7 @@ fn taffy_issue_696_min_height__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -17,6 +18,10 @@ fn taffy_issue_696_min_height__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(0f32), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, padding: taffy::geometry::Rect { @@ -35,6 +40,10 @@ fn taffy_issue_696_min_height__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -45,24 +54,137 @@ fn taffy_issue_696_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 120f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 120f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +197,7 @@ fn taffy_issue_696_min_height__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -86,6 +209,10 @@ fn taffy_issue_696_min_height__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_basis: taffy::style::Dimension::from_length(0f32), min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, padding: taffy::geometry::Rect { @@ -105,6 +232,10 @@ fn taffy_issue_696_min_height__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -115,22 +246,135 @@ fn taffy_issue_696_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 80f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 140f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 80f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/taffy_issue_696_no_flex_basis.rs b/tests/generated/flex/taffy_issue_696_no_flex_basis.rs index 27b4648d5..9ffdf76c2 100644 --- a/tests/generated/flex/taffy_issue_696_no_flex_basis.rs +++ b/tests/generated/flex/taffy_issue_696_no_flex_basis.rs @@ -7,6 +7,7 @@ fn taffy_issue_696_no_flex_basis__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -39,6 +40,10 @@ fn taffy_issue_696_no_flex_basis__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -49,42 +54,137 @@ fn taffy_issue_696_no_flex_basis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +197,7 @@ fn taffy_issue_696_no_flex_basis__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -131,6 +232,10 @@ fn taffy_issue_696_no_flex_basis__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -141,40 +246,135 @@ fn taffy_issue_696_no_flex_basis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 240f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/taffy_issue_696_overflow_hidden.rs b/tests/generated/flex/taffy_issue_696_overflow_hidden.rs index 8969cd368..616fa37fa 100644 --- a/tests/generated/flex/taffy_issue_696_overflow_hidden.rs +++ b/tests/generated/flex/taffy_issue_696_overflow_hidden.rs @@ -7,6 +7,7 @@ fn taffy_issue_696_overflow_hidden__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -39,6 +40,10 @@ fn taffy_issue_696_overflow_hidden__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -49,42 +54,131 @@ fn taffy_issue_696_overflow_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 200f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 200f32, - layout.scroll_height() - ); + if layout.scroll_height() != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 200f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,6 +191,7 @@ fn taffy_issue_696_overflow_hidden__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_shrink: 0f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) }, ..Default::default() @@ -131,6 +226,10 @@ fn taffy_issue_696_overflow_hidden__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -141,40 +240,129 @@ fn taffy_issue_696_overflow_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 200f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 200f32, - layout.scroll_height() - ); + if layout.scroll_height() != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 200f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/undefined_height_with_min_max.rs b/tests/generated/flex/undefined_height_with_min_max.rs index 71916d7a1..ddb40528d 100644 --- a/tests/generated/flex/undefined_height_with_min_max.rs +++ b/tests/generated/flex/undefined_height_with_min_max.rs @@ -6,6 +6,7 @@ fn undefined_height_with_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -15,6 +16,10 @@ fn undefined_height_with_min_max__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, ..Default::default() @@ -26,18 +31,86 @@ fn undefined_height_with_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,6 +122,7 @@ fn undefined_height_with_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) }, ..Default::default() @@ -59,6 +133,10 @@ fn undefined_height_with_min_max__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) }, ..Default::default() @@ -70,16 +148,84 @@ fn undefined_height_with_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/undefined_width_with_min_max.rs b/tests/generated/flex/undefined_width_with_min_max.rs index 0a6d329a8..afb1ca668 100644 --- a/tests/generated/flex/undefined_width_with_min_max.rs +++ b/tests/generated/flex/undefined_width_with_min_max.rs @@ -6,6 +6,7 @@ fn undefined_width_with_min_max__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -15,6 +16,10 @@ fn undefined_width_with_min_max__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -25,18 +30,86 @@ fn undefined_width_with_min_max__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,6 +121,7 @@ fn undefined_width_with_min_max__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -58,6 +132,10 @@ fn undefined_width_with_min_max__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -68,16 +146,84 @@ fn undefined_width_with_min_max__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/undefined_width_with_min_max_row.rs b/tests/generated/flex/undefined_width_with_min_max_row.rs index ddd5ef770..ed29db9ea 100644 --- a/tests/generated/flex/undefined_width_with_min_max_row.rs +++ b/tests/generated/flex/undefined_width_with_min_max_row.rs @@ -6,6 +6,7 @@ fn undefined_width_with_min_max_row__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,10 @@ fn undefined_width_with_min_max_row__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -26,6 +31,10 @@ fn undefined_width_with_min_max_row__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -36,24 +45,131 @@ fn undefined_width_with_min_max_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +181,7 @@ fn undefined_width_with_min_max_row__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -76,6 +193,10 @@ fn undefined_width_with_min_max_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -87,6 +208,10 @@ fn undefined_width_with_min_max_row__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, ..Default::default() }, @@ -97,22 +222,129 @@ fn undefined_width_with_min_max_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/width_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex/width_smaller_then_content_with_flex_grow_large_size.rs index 36a380b13..b52689375 100644 --- a/tests/generated/flex/width_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex/width_smaller_then_content_with_flex_grow_large_size.rs @@ -6,6 +6,7 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -26,6 +31,7 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -47,6 +57,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn width_smaller_then_content_with_flex_grow_large_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -120,6 +330,7 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -143,6 +358,10 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn width_smaller_then_content_with_flex_grow_large_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/width_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/flex/width_smaller_then_content_with_flex_grow_small_size.rs index 38cb36d98..55d367611 100644 --- a/tests/generated/flex/width_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/flex/width_smaller_then_content_with_flex_grow_small_size.rs @@ -6,6 +6,7 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -26,6 +31,7 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -47,6 +57,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn width_smaller_then_content_with_flex_grow_small_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 60f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node0, 5f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 5f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node1, 5f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 5f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -120,6 +330,7 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -143,6 +358,10 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn width_smaller_then_content_with_flex_grow_small_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 60f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node0, 5f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 5f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node1, 5f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 5f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 15f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size.rs index a64607063..06c5462e6 100644 --- a/tests/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/flex/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -6,6 +6,7 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -26,6 +31,7 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -44,41 +54,243 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__border_box() { &[node10], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 70f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 70f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +302,7 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -102,6 +315,10 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -112,6 +329,7 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -124,6 +342,10 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -133,7 +355,14 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -141,34 +370,225 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 70f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 70f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 70f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size.rs index a617ec764..75e837aa3 100644 --- a/tests/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/flex/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -6,6 +6,7 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -17,6 +18,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -26,6 +31,7 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -37,6 +43,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -47,6 +57,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -57,36 +71,227 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,6 +303,7 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: taffy::style::Dimension::from_length(100f32), @@ -110,6 +316,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -120,6 +330,7 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(100f32), @@ -132,6 +343,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: auto() }, ..Default::default() @@ -143,6 +358,10 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -153,34 +372,225 @@ fn width_smaller_then_content_with_flex_grow_very_large_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_child.rs b/tests/generated/flex/wrap_child.rs index 8a4df9b28..d3d982418 100644 --- a/tests/generated/flex/wrap_child.rs +++ b/tests/generated/flex/wrap_child.rs @@ -6,6 +6,7 @@ fn wrap_child__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -15,7 +16,14 @@ fn wrap_child__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -23,18 +31,92 @@ fn wrap_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +128,7 @@ fn wrap_child__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -58,6 +141,10 @@ fn wrap_child__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -67,16 +154,90 @@ fn wrap_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_column.rs b/tests/generated/flex/wrap_column.rs index ce5d3adbf..df7a1cdcd 100644 --- a/tests/generated/flex/wrap_column.rs +++ b/tests/generated/flex/wrap_column.rs @@ -6,6 +6,7 @@ fn wrap_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(31f32), @@ -15,6 +16,7 @@ fn wrap_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(32f32), @@ -24,6 +26,7 @@ fn wrap_column__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(33f32), @@ -33,6 +36,7 @@ fn wrap_column__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(34f32), @@ -45,6 +49,10 @@ fn wrap_column__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -58,36 +66,203 @@ fn wrap_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 63f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +274,7 @@ fn wrap_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(31f32), @@ -109,6 +285,7 @@ fn wrap_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(32f32), @@ -119,6 +296,7 @@ fn wrap_column__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(33f32), @@ -129,6 +307,7 @@ fn wrap_column__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(34f32), @@ -142,6 +321,10 @@ fn wrap_column__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -155,34 +338,201 @@ fn wrap_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 63f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_grandchild.rs b/tests/generated/flex/wrap_grandchild.rs index 1b86e9978..164e3aae7 100644 --- a/tests/generated/flex/wrap_grandchild.rs +++ b/tests/generated/flex/wrap_grandchild.rs @@ -6,6 +6,7 @@ fn wrap_grandchild__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -13,30 +14,165 @@ fn wrap_grandchild__border_box() { ..Default::default() }) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,6 +184,7 @@ fn wrap_grandchild__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -57,13 +194,27 @@ fn wrap_grandchild__content_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -71,22 +222,135 @@ fn wrap_grandchild__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs b/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs index 9a1adcaaa..bbb696a31 100644 --- a/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs +++ b/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs @@ -6,6 +6,7 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -15,12 +16,20 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { .unwrap(); let node00 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node000], ) .unwrap(); let node010 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -32,6 +41,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -42,6 +55,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: auto() }, ..Default::default() }, @@ -52,6 +69,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -65,42 +86,266 @@ fn wrap_nodes_with_content_sizing_margin_cross__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node01, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node010, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +357,7 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -124,6 +370,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node000], @@ -132,6 +382,7 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { let node010 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -144,6 +395,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: zero(), top: length(10f32), bottom: zero() }, ..Default::default() }, @@ -155,6 +410,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(70f32), height: auto() }, ..Default::default() }, @@ -166,6 +425,10 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -179,40 +442,264 @@ fn wrap_nodes_with_content_sizing_margin_cross__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); - assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 90f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node01, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node010, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs b/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs index 86c76156b..274ca8471 100644 --- a/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs +++ b/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -6,6 +6,7 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -15,12 +16,20 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { .unwrap(); let node00 = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node000], ) .unwrap(); let node010 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -32,6 +41,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() }, @@ -42,6 +55,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(85f32), height: auto() }, ..Default::default() }, @@ -52,6 +69,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -65,42 +86,266 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0, 85f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node010, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,6 +357,7 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -124,6 +370,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node000], @@ -132,6 +382,7 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { let node010 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(40f32), @@ -144,6 +395,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: zero(), right: length(10f32), top: zero(), bottom: zero() }, ..Default::default() }, @@ -155,6 +410,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(85f32), height: auto() }, ..Default::default() }, @@ -166,6 +425,10 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(500f32), height: taffy::style::Dimension::from_length(500f32), @@ -179,40 +442,264 @@ fn wrap_nodes_with_content_sizing_overflowing_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 500f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0, 85f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 85f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 85f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node010, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_column.rs b/tests/generated/flex/wrap_reverse_column.rs index 107ddbd9a..5c9d19cff 100644 --- a/tests/generated/flex/wrap_reverse_column.rs +++ b/tests/generated/flex/wrap_reverse_column.rs @@ -6,6 +6,7 @@ fn wrap_reverse_column__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(31f32), @@ -15,6 +16,7 @@ fn wrap_reverse_column__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(32f32), @@ -24,6 +26,7 @@ fn wrap_reverse_column__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(33f32), @@ -33,6 +36,7 @@ fn wrap_reverse_column__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(34f32), @@ -45,6 +49,10 @@ fn wrap_reverse_column__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -58,36 +66,203 @@ fn wrap_reverse_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 63f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +274,7 @@ fn wrap_reverse_column__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(31f32), @@ -109,6 +285,7 @@ fn wrap_reverse_column__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(32f32), @@ -119,6 +296,7 @@ fn wrap_reverse_column__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(33f32), @@ -129,6 +307,7 @@ fn wrap_reverse_column__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(34f32), @@ -142,6 +321,10 @@ fn wrap_reverse_column__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -155,34 +338,201 @@ fn wrap_reverse_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 31f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 33f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 63f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 34f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_column_fixed_size.rs b/tests/generated/flex/wrap_reverse_column_fixed_size.rs index 0c3a1bfda..baf89d0d2 100644 --- a/tests/generated/flex/wrap_reverse_column_fixed_size.rs +++ b/tests/generated/flex/wrap_reverse_column_fixed_size.rs @@ -6,6 +6,7 @@ fn wrap_reverse_column_fixed_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_column_fixed_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_column_fixed_size__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_column_fixed_size__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_column_fixed_size__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -54,6 +59,10 @@ fn wrap_reverse_column_fixed_size__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -68,42 +77,242 @@ fn wrap_reverse_column_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node0, 135f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node1, 135f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node2, 135f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node3, 135f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node4, 35f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -115,6 +324,7 @@ fn wrap_reverse_column_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -125,6 +335,7 @@ fn wrap_reverse_column_fixed_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -135,6 +346,7 @@ fn wrap_reverse_column_fixed_size__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -145,6 +357,7 @@ fn wrap_reverse_column_fixed_size__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -155,6 +368,7 @@ fn wrap_reverse_column_fixed_size__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -168,6 +382,10 @@ fn wrap_reverse_column_fixed_size__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -182,40 +400,240 @@ fn wrap_reverse_column_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node0, 135f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node1, 135f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node2, 135f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node3, 135f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node4, 35f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 35f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row.rs b/tests/generated/flex/wrap_reverse_row.rs index c762a9a6e..20ea11f44 100644 --- a/tests/generated/flex/wrap_reverse_row.rs +++ b/tests/generated/flex/wrap_reverse_row.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(31f32), height: taffy::style::Dimension::from_length(30f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(32f32), height: taffy::style::Dimension::from_length(30f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(33f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(34f32), height: taffy::style::Dimension::from_length(30f32), @@ -44,6 +48,10 @@ fn wrap_reverse_row__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -54,36 +62,203 @@ fn wrap_reverse_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 31f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +270,7 @@ fn wrap_reverse_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(31f32), height: taffy::style::Dimension::from_length(30f32), @@ -105,6 +281,7 @@ fn wrap_reverse_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(32f32), height: taffy::style::Dimension::from_length(30f32), @@ -115,6 +292,7 @@ fn wrap_reverse_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(33f32), height: taffy::style::Dimension::from_length(30f32), @@ -125,6 +303,7 @@ fn wrap_reverse_row__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(34f32), height: taffy::style::Dimension::from_length(30f32), @@ -137,6 +316,10 @@ fn wrap_reverse_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -147,34 +330,201 @@ fn wrap_reverse_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 31f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row_align_content_center.rs b/tests/generated/flex/wrap_reverse_row_align_content_center.rs index e49dad9ad..71d407c2f 100644 --- a/tests/generated/flex/wrap_reverse_row_align_content_center.rs +++ b/tests/generated/flex/wrap_reverse_row_align_content_center.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row_align_content_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row_align_content_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row_align_content_center__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row_align_content_center__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_row_align_content_center__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -53,6 +58,10 @@ fn wrap_reverse_row_align_content_center__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -64,42 +73,242 @@ fn wrap_reverse_row_align_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn wrap_reverse_row_align_content_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +331,7 @@ fn wrap_reverse_row_align_content_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -131,6 +342,7 @@ fn wrap_reverse_row_align_content_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +353,7 @@ fn wrap_reverse_row_align_content_center__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -151,6 +364,7 @@ fn wrap_reverse_row_align_content_center__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -163,6 +377,10 @@ fn wrap_reverse_row_align_content_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -174,40 +392,240 @@ fn wrap_reverse_row_align_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs b/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs index c11226dc3..537365595 100644 --- a/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs +++ b/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -53,6 +58,10 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -64,42 +73,242 @@ fn wrap_reverse_row_align_content_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +331,7 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -131,6 +342,7 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +353,7 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -151,6 +364,7 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -163,6 +377,10 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -174,40 +392,240 @@ fn wrap_reverse_row_align_content_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs b/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs index b2196df1d..cc91575a9 100644 --- a/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs +++ b/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row_align_content_space_around__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row_align_content_space_around__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row_align_content_space_around__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row_align_content_space_around__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_row_align_content_space_around__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -53,6 +58,10 @@ fn wrap_reverse_row_align_content_space_around__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -64,42 +73,242 @@ fn wrap_reverse_row_align_content_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn wrap_reverse_row_align_content_space_around__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +331,7 @@ fn wrap_reverse_row_align_content_space_around__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -131,6 +342,7 @@ fn wrap_reverse_row_align_content_space_around__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +353,7 @@ fn wrap_reverse_row_align_content_space_around__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -151,6 +364,7 @@ fn wrap_reverse_row_align_content_space_around__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -163,6 +377,10 @@ fn wrap_reverse_row_align_content_space_around__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -174,40 +392,240 @@ fn wrap_reverse_row_align_content_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs b/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs index 9e7603d35..80c6efa36 100644 --- a/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs +++ b/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row_align_content_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row_align_content_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row_align_content_stretch__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row_align_content_stretch__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_row_align_content_stretch__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -53,6 +58,10 @@ fn wrap_reverse_row_align_content_stretch__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -64,42 +73,242 @@ fn wrap_reverse_row_align_content_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn wrap_reverse_row_align_content_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +331,7 @@ fn wrap_reverse_row_align_content_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -131,6 +342,7 @@ fn wrap_reverse_row_align_content_stretch__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +353,7 @@ fn wrap_reverse_row_align_content_stretch__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -151,6 +364,7 @@ fn wrap_reverse_row_align_content_stretch__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -163,6 +377,10 @@ fn wrap_reverse_row_align_content_stretch__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -174,40 +392,240 @@ fn wrap_reverse_row_align_content_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs b/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs index 8e4ff528a..d97030876 100644 --- a/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs +++ b/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs @@ -6,6 +6,7 @@ fn wrap_reverse_row_single_line_different_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_reverse_row_single_line_different_size__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_reverse_row_single_line_different_size__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_reverse_row_single_line_different_size__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -42,6 +46,7 @@ fn wrap_reverse_row_single_line_different_size__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -53,6 +58,10 @@ fn wrap_reverse_row_single_line_different_size__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -64,42 +73,242 @@ fn wrap_reverse_row_single_line_different_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node3, 90f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -111,6 +320,7 @@ fn wrap_reverse_row_single_line_different_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -121,6 +331,7 @@ fn wrap_reverse_row_single_line_different_size__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -131,6 +342,7 @@ fn wrap_reverse_row_single_line_different_size__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +353,7 @@ fn wrap_reverse_row_single_line_different_size__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(40f32), @@ -151,6 +364,7 @@ fn wrap_reverse_row_single_line_different_size__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -163,6 +377,10 @@ fn wrap_reverse_row_single_line_different_size__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::WrapReverse, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() }, ..Default::default() @@ -174,40 +392,240 @@ fn wrap_reverse_row_single_line_different_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 300f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node3, 90f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_row.rs b/tests/generated/flex/wrap_row.rs index 8cb72cbfb..4bc57d7fd 100644 --- a/tests/generated/flex/wrap_row.rs +++ b/tests/generated/flex/wrap_row.rs @@ -6,6 +6,7 @@ fn wrap_row__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(31f32), height: taffy::style::Dimension::from_length(30f32), @@ -15,6 +16,7 @@ fn wrap_row__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(32f32), height: taffy::style::Dimension::from_length(30f32), @@ -24,6 +26,7 @@ fn wrap_row__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(33f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_row__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(34f32), height: taffy::style::Dimension::from_length(30f32), @@ -44,6 +48,10 @@ fn wrap_row__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -54,36 +62,203 @@ fn wrap_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 31f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,6 +270,7 @@ fn wrap_row__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(31f32), height: taffy::style::Dimension::from_length(30f32), @@ -105,6 +281,7 @@ fn wrap_row__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(32f32), height: taffy::style::Dimension::from_length(30f32), @@ -115,6 +292,7 @@ fn wrap_row__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(33f32), height: taffy::style::Dimension::from_length(30f32), @@ -125,6 +303,7 @@ fn wrap_row__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(34f32), height: taffy::style::Dimension::from_length(30f32), @@ -137,6 +316,10 @@ fn wrap_row__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }, @@ -147,34 +330,201 @@ fn wrap_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 31f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 31f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 63f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 63f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_row_align_items_center.rs b/tests/generated/flex/wrap_row_align_items_center.rs index ebb6a5686..b0788252d 100644 --- a/tests/generated/flex/wrap_row_align_items_center.rs +++ b/tests/generated/flex/wrap_row_align_items_center.rs @@ -6,6 +6,7 @@ fn wrap_row_align_items_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_row_align_items_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_row_align_items_center__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_row_align_items_center__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -44,6 +48,10 @@ fn wrap_row_align_items_center__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -55,36 +63,203 @@ fn wrap_row_align_items_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -96,6 +271,7 @@ fn wrap_row_align_items_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -106,6 +282,7 @@ fn wrap_row_align_items_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -116,6 +293,7 @@ fn wrap_row_align_items_center__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -126,6 +304,7 @@ fn wrap_row_align_items_center__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -138,6 +317,10 @@ fn wrap_row_align_items_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -149,34 +332,201 @@ fn wrap_row_align_items_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrap_row_align_items_flex_end.rs b/tests/generated/flex/wrap_row_align_items_flex_end.rs index ed9bb1596..4721acc9c 100644 --- a/tests/generated/flex/wrap_row_align_items_flex_end.rs +++ b/tests/generated/flex/wrap_row_align_items_flex_end.rs @@ -6,6 +6,7 @@ fn wrap_row_align_items_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -15,6 +16,7 @@ fn wrap_row_align_items_flex_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -24,6 +26,7 @@ fn wrap_row_align_items_flex_end__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -33,6 +36,7 @@ fn wrap_row_align_items_flex_end__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -44,6 +48,10 @@ fn wrap_row_align_items_flex_end__border_box() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -55,36 +63,203 @@ fn wrap_row_align_items_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -96,6 +271,7 @@ fn wrap_row_align_items_flex_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(10f32), @@ -106,6 +282,7 @@ fn wrap_row_align_items_flex_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(20f32), @@ -116,6 +293,7 @@ fn wrap_row_align_items_flex_end__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -126,6 +304,7 @@ fn wrap_row_align_items_flex_end__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(30f32), @@ -138,6 +317,10 @@ fn wrap_row_align_items_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -149,34 +332,201 @@ fn wrap_row_align_items_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrapped_column_max_height.rs b/tests/generated/flex/wrapped_column_max_height.rs index a95ad7ba8..5ae1ded37 100644 --- a/tests/generated/flex/wrapped_column_max_height.rs +++ b/tests/generated/flex/wrapped_column_max_height.rs @@ -6,6 +6,7 @@ fn wrapped_column_max_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(500f32), @@ -16,6 +17,7 @@ fn wrapped_column_max_height__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -31,6 +33,7 @@ fn wrapped_column_max_height__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -43,6 +46,10 @@ fn wrapped_column_max_height__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -59,30 +66,182 @@ fn wrapped_column_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 700f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 700f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node0, 250f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node1, 250f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 420f32, "x of node {:?}. Expected {}. Actual {}", node2, 420f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node2, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 420f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 420f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -94,6 +253,7 @@ fn wrapped_column_max_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(500f32), @@ -105,6 +265,7 @@ fn wrapped_column_max_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -121,6 +282,7 @@ fn wrapped_column_max_height__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -134,6 +296,10 @@ fn wrapped_column_max_height__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -150,28 +316,180 @@ fn wrapped_column_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 700f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 700f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node0, 250f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node1, 250f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 420f32, "x of node {:?}. Expected {}. Actual {}", node2, 420f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node2, 200f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 420f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 420f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrapped_column_max_height_flex.rs b/tests/generated/flex/wrapped_column_max_height_flex.rs index dbaa770d3..84d039d6b 100644 --- a/tests/generated/flex/wrapped_column_max_height_flex.rs +++ b/tests/generated/flex/wrapped_column_max_height_flex.rs @@ -6,6 +6,7 @@ fn wrapped_column_max_height_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -19,6 +20,7 @@ fn wrapped_column_max_height_flex__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -37,6 +39,7 @@ fn wrapped_column_max_height_flex__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -49,6 +52,10 @@ fn wrapped_column_max_height_flex__border_box() { taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -65,30 +72,182 @@ fn wrapped_column_max_height_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 700f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 700f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node0, 180f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node0, 300f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node1, 180f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node2, 300f32, location.x); - assert_eq!(location.y, 400f32, "y of node {:?}. Expected {}. Actual {}", node2, 400f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 400f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +259,7 @@ fn wrapped_column_max_height_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -114,6 +274,7 @@ fn wrapped_column_max_height_flex__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::from_percent(0f32), @@ -133,6 +294,7 @@ fn wrapped_column_max_height_flex__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -146,6 +308,10 @@ fn wrapped_column_max_height_flex__content_box() { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), @@ -162,28 +328,180 @@ fn wrapped_column_max_height_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); - assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 700f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 700f32, layout.size.width); + } + if layout.size.height != 500f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 500f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node0, 180f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node0, 300f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node1, 180f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); - assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 180f32, + layout.size.height + ); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 200f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node2, 300f32, location.x); - assert_eq!(location.y, 400f32, "y of node {:?}. Expected {}. Actual {}", node2, 400f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 300f32, layout.location.x); + } + if layout.location.y != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 400f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrapped_row_within_align_items_center.rs b/tests/generated/flex/wrapped_row_within_align_items_center.rs index f0290f20a..7d7dabd8d 100644 --- a/tests/generated/flex/wrapped_row_within_align_items_center.rs +++ b/tests/generated/flex/wrapped_row_within_align_items_center.rs @@ -6,6 +6,7 @@ fn wrapped_row_within_align_items_center__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -15,6 +16,7 @@ fn wrapped_row_within_align_items_center__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -24,7 +26,14 @@ fn wrapped_row_within_align_items_center__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00, node01], ) .unwrap(); @@ -32,6 +41,10 @@ fn wrapped_row_within_align_items_center__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,30 +59,182 @@ fn wrapped_row_within_align_items_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,6 +246,7 @@ fn wrapped_row_within_align_items_center__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -91,6 +257,7 @@ fn wrapped_row_within_align_items_center__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -103,6 +270,10 @@ fn wrapped_row_within_align_items_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01], @@ -113,6 +284,10 @@ fn wrapped_row_within_align_items_center__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -127,28 +302,180 @@ fn wrapped_row_within_align_items_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs b/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs index 791cfa5c8..b0329d7a0 100644 --- a/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs +++ b/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs @@ -6,6 +6,7 @@ fn wrapped_row_within_align_items_flex_end__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -15,6 +16,7 @@ fn wrapped_row_within_align_items_flex_end__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -24,7 +26,14 @@ fn wrapped_row_within_align_items_flex_end__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00, node01], ) .unwrap(); @@ -32,6 +41,10 @@ fn wrapped_row_within_align_items_flex_end__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,30 +59,182 @@ fn wrapped_row_within_align_items_flex_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,6 +246,7 @@ fn wrapped_row_within_align_items_flex_end__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -91,6 +257,7 @@ fn wrapped_row_within_align_items_flex_end__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -103,6 +270,10 @@ fn wrapped_row_within_align_items_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01], @@ -113,6 +284,10 @@ fn wrapped_row_within_align_items_flex_end__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -127,28 +302,180 @@ fn wrapped_row_within_align_items_flex_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs b/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs index 07bea8723..f06414cc5 100644 --- a/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs +++ b/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs @@ -6,6 +6,7 @@ fn wrapped_row_within_align_items_flex_start__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -15,6 +16,7 @@ fn wrapped_row_within_align_items_flex_start__border_box() { .unwrap(); let node01 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -24,7 +26,14 @@ fn wrapped_row_within_align_items_flex_start__border_box() { .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00, node01], ) .unwrap(); @@ -32,6 +41,10 @@ fn wrapped_row_within_align_items_flex_start__border_box() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -46,30 +59,182 @@ fn wrapped_row_within_align_items_flex_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,6 +246,7 @@ fn wrapped_row_within_align_items_flex_start__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(150f32), height: taffy::style::Dimension::from_length(80f32), @@ -91,6 +257,7 @@ fn wrapped_row_within_align_items_flex_start__content_box() { let node01 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: taffy::style::Dimension::from_length(80f32), @@ -103,6 +270,10 @@ fn wrapped_row_within_align_items_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01], @@ -113,6 +284,10 @@ fn wrapped_row_within_align_items_flex_start__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -127,28 +302,180 @@ fn wrapped_row_within_align_items_flex_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/chrome_issue_325928327.rs b/tests/generated/grid/chrome_issue_325928327.rs index 8658f667b..39baf4707 100644 --- a/tests/generated/grid/chrome_issue_325928327.rs +++ b/tests/generated/grid/chrome_issue_325928327.rs @@ -6,6 +6,7 @@ fn chrome_issue_325928327__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, aspect_ratio: Some(1f32), ..Default::default() @@ -14,6 +15,10 @@ fn chrome_issue_325928327__border_box() { let node0 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() }, @@ -24,6 +29,10 @@ fn chrome_issue_325928327__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -38,24 +47,131 @@ fn chrome_issue_325928327__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +183,7 @@ fn chrome_issue_325928327__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, aspect_ratio: Some(1f32), ..Default::default() @@ -76,6 +193,10 @@ fn chrome_issue_325928327__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(1f32) }, ..Default::default() }, @@ -87,6 +208,10 @@ fn chrome_issue_325928327__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), @@ -101,22 +226,129 @@ fn chrome_issue_325928327__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_align_self_sized_all.rs b/tests/generated/grid/grid_absolute_align_self_sized_all.rs index 76fdc2f27..33f7e36f0 100644 --- a/tests/generated/grid/grid_absolute_align_self_sized_all.rs +++ b/tests/generated/grid/grid_absolute_align_self_sized_all.rs @@ -7,6 +7,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -29,6 +31,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -40,6 +43,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -51,6 +55,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node4 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -62,6 +67,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node5 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -73,6 +79,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node6 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -84,6 +91,7 @@ fn grid_absolute_align_self_sized_all__border_box() { let node7 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -96,6 +104,10 @@ fn grid_absolute_align_self_sized_all__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -111,60 +123,359 @@ fn grid_absolute_align_self_sized_all__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -177,6 +488,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -189,6 +501,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -201,6 +514,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -213,6 +527,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -225,6 +540,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -237,6 +553,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -249,6 +566,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -261,6 +579,7 @@ fn grid_absolute_align_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -274,6 +593,10 @@ fn grid_absolute_align_self_sized_all__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -289,58 +612,357 @@ fn grid_absolute_align_self_sized_all__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_column_end.rs b/tests/generated/grid/grid_absolute_column_end.rs index 895e89d48..d010aaaa2 100644 --- a/tests/generated/grid/grid_absolute_column_end.rs +++ b/tests/generated/grid/grid_absolute_column_end.rs @@ -7,6 +7,7 @@ fn grid_absolute_column_end__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, inset: taffy::geometry::Rect { left: length(4f32), @@ -21,6 +22,10 @@ fn grid_absolute_column_end__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -38,18 +43,92 @@ fn grid_absolute_column_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 157f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 157f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +141,7 @@ fn grid_absolute_column_end__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, inset: taffy::geometry::Rect { left: length(4f32), @@ -77,6 +157,10 @@ fn grid_absolute_column_end__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -94,16 +178,90 @@ fn grid_absolute_column_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 157f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 157f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_column_start.rs b/tests/generated/grid/grid_absolute_column_start.rs index 2888f98f5..244287603 100644 --- a/tests/generated/grid/grid_absolute_column_start.rs +++ b/tests/generated/grid/grid_absolute_column_start.rs @@ -7,6 +7,7 @@ fn grid_absolute_column_start__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, inset: taffy::geometry::Rect { left: length(4f32), @@ -21,6 +22,10 @@ fn grid_absolute_column_start__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -38,18 +43,92 @@ fn grid_absolute_column_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 133f32, "width of node {:?}. Expected {}. Actual {}", node0, 133f32, size.width); - assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 133f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 133f32, layout.size.width); + } + if layout.size.height != 157f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 157f32, + layout.size.height + ); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +141,7 @@ fn grid_absolute_column_start__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, inset: taffy::geometry::Rect { left: length(4f32), @@ -77,6 +157,10 @@ fn grid_absolute_column_start__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -94,16 +178,90 @@ fn grid_absolute_column_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 133f32, "width of node {:?}. Expected {}. Actual {}", node0, 133f32, size.width); - assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 133f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 133f32, layout.size.width); + } + if layout.size.height != 157f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 157f32, + layout.size.height + ); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_bottom_left.rs b/tests/generated/grid/grid_absolute_container_bottom_left.rs index 8f3bcad1b..dc4544335 100644 --- a/tests/generated/grid/grid_absolute_container_bottom_left.rs +++ b/tests/generated/grid/grid_absolute_container_bottom_left.rs @@ -7,22 +7,67 @@ fn grid_absolute_container_bottom_left__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: auto(), bottom: length(0f32) }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -40,66 +85,398 @@ fn grid_absolute_container_bottom_left__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node0, 160f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,39 +489,76 @@ fn grid_absolute_container_bottom_left__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: auto(), bottom: length(0f32) }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -162,64 +576,396 @@ fn grid_absolute_container_bottom_left__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node0, 160f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs b/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs index 384bd7746..d3093cf6f 100644 --- a/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs +++ b/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_bottom_left_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -21,18 +22,62 @@ fn grid_absolute_container_bottom_left_margin__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -50,66 +95,398 @@ fn grid_absolute_container_bottom_left_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node0, 147f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -122,6 +499,7 @@ fn grid_absolute_container_bottom_left_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -137,34 +515,70 @@ fn grid_absolute_container_bottom_left_margin__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -182,64 +596,396 @@ fn grid_absolute_container_bottom_left_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node0, 147f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_left_overrides_right.rs b/tests/generated/grid/grid_absolute_container_left_overrides_right.rs index dca8245ff..3e573995b 100644 --- a/tests/generated/grid/grid_absolute_container_left_overrides_right.rs +++ b/tests/generated/grid/grid_absolute_container_left_overrides_right.rs @@ -7,23 +7,68 @@ fn grid_absolute_container_left_overrides_right__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: length(5f32), right: length(2f32), top: auto(), bottom: auto() }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -41,66 +86,398 @@ fn grid_absolute_container_left_overrides_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,40 +490,77 @@ fn grid_absolute_container_left_overrides_right__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, inset: taffy::geometry::Rect { left: length(5f32), right: length(2f32), top: auto(), bottom: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -164,64 +578,396 @@ fn grid_absolute_container_left_overrides_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_left_right.rs b/tests/generated/grid/grid_absolute_container_left_right.rs index d1855a7a9..147257971 100644 --- a/tests/generated/grid/grid_absolute_container_left_right.rs +++ b/tests/generated/grid/grid_absolute_container_left_right.rs @@ -7,22 +7,67 @@ fn grid_absolute_container_left_right__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(5f32), right: length(2f32), top: auto(), bottom: auto() }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -40,66 +85,398 @@ fn grid_absolute_container_left_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,39 +489,76 @@ fn grid_absolute_container_left_right__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(5f32), right: length(2f32), top: auto(), bottom: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -162,64 +576,396 @@ fn grid_absolute_container_left_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_left_right_margin.rs b/tests/generated/grid/grid_absolute_container_left_right_margin.rs index 63fee83c6..9f3a60eec 100644 --- a/tests/generated/grid/grid_absolute_container_left_right_margin.rs +++ b/tests/generated/grid/grid_absolute_container_left_right_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_left_right_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -17,18 +18,62 @@ fn grid_absolute_container_left_right_margin__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -46,66 +91,398 @@ fn grid_absolute_container_left_right_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 167f32, "width of node {:?}. Expected {}. Actual {}", node0, 167f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node0, 9f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 167f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 167f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 9f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,6 +495,7 @@ fn grid_absolute_container_left_right_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -129,34 +507,70 @@ fn grid_absolute_container_left_right_margin__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -174,64 +588,396 @@ fn grid_absolute_container_left_right_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 167f32, "width of node {:?}. Expected {}. Actual {}", node0, 167f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node0, 9f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 167f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 167f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 9f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_negative_position.rs b/tests/generated/grid/grid_absolute_container_negative_position.rs index 4eb0b42ee..7c5f53706 100644 --- a/tests/generated/grid/grid_absolute_container_negative_position.rs +++ b/tests/generated/grid/grid_absolute_container_negative_position.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_negative_position__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(-15f32), top: length(-5f32), bottom: auto() }, ..Default::default() }) @@ -14,21 +15,61 @@ fn grid_absolute_container_negative_position__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(-35f32), right: auto(), top: auto(), bottom: length(-25f32) }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -46,66 +87,398 @@ fn grid_absolute_container_negative_position__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node0, 195f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, -35f32, "x of node {:?}. Expected {}. Actual {}", node1, -35f32, location.x); - assert_eq!(location.y, 185f32, "y of node {:?}. Expected {}. Actual {}", node1, 185f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -35f32, layout.location.x); + } + if layout.location.y != 185f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 185f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,6 +491,7 @@ fn grid_absolute_container_negative_position__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(-15f32), top: length(-5f32), bottom: auto() }, ..Default::default() }) @@ -126,36 +500,69 @@ fn grid_absolute_container_negative_position__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(-35f32), right: auto(), top: auto(), bottom: length(-25f32) }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -173,64 +580,396 @@ fn grid_absolute_container_negative_position__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node0, 195f32, location.x); - assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != -5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, -35f32, "x of node {:?}. Expected {}. Actual {}", node1, -35f32, location.x); - assert_eq!(location.y, 185f32, "y of node {:?}. Expected {}. Actual {}", node1, 185f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != -35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -35f32, layout.location.x); + } + if layout.location.y != 185f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 185f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_negative_position_margin.rs b/tests/generated/grid/grid_absolute_container_negative_position_margin.rs index 5233c68a2..0b0dba2e5 100644 --- a/tests/generated/grid/grid_absolute_container_negative_position_margin.rs +++ b/tests/generated/grid/grid_absolute_container_negative_position_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_negative_position_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -20,6 +21,7 @@ fn grid_absolute_container_negative_position_margin__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -30,17 +32,56 @@ fn grid_absolute_container_negative_position_margin__border_box() { ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -58,66 +99,398 @@ fn grid_absolute_container_negative_position_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node0, 193f32, location.x); - assert_eq!(location.y, -4f32, "y of node {:?}. Expected {}. Actual {}", node0, -4f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 193f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 193f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, -31f32, "x of node {:?}. Expected {}. Actual {}", node1, -31f32, location.x); - assert_eq!(location.y, 182f32, "y of node {:?}. Expected {}. Actual {}", node1, 182f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != -31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -31f32, layout.location.x); + } + if layout.location.y != 182f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 182f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +503,7 @@ fn grid_absolute_container_negative_position_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -144,6 +518,7 @@ fn grid_absolute_container_negative_position_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -155,31 +530,63 @@ fn grid_absolute_container_negative_position_margin__content_box() { }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -197,64 +604,396 @@ fn grid_absolute_container_negative_position_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node0, 193f32, location.x); - assert_eq!(location.y, -4f32, "y of node {:?}. Expected {}. Actual {}", node0, -4f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 193f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 193f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, -31f32, "x of node {:?}. Expected {}. Actual {}", node1, -31f32, location.x); - assert_eq!(location.y, 182f32, "y of node {:?}. Expected {}. Actual {}", node1, 182f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != -31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), -31f32, layout.location.x); + } + if layout.location.y != 182f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 182f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_top_bottom.rs b/tests/generated/grid/grid_absolute_container_top_bottom.rs index 384d896da..9e1ac7a31 100644 --- a/tests/generated/grid/grid_absolute_container_top_bottom.rs +++ b/tests/generated/grid/grid_absolute_container_top_bottom.rs @@ -7,22 +7,67 @@ fn grid_absolute_container_top_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(2f32), bottom: length(5f32) }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -40,66 +85,404 @@ fn grid_absolute_container_top_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 153f32, "height of node {:?}. Expected {}. Actual {}", node0, 153f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 153f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 153f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,39 +495,76 @@ fn grid_absolute_container_top_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(2f32), bottom: length(5f32) }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -162,64 +582,402 @@ fn grid_absolute_container_top_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 153f32, "height of node {:?}. Expected {}. Actual {}", node0, 153f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 153f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 153f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs b/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs index 9fa04d29a..9b4429c0e 100644 --- a/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs +++ b/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_top_bottom_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -17,18 +18,62 @@ fn grid_absolute_container_top_bottom_margin__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -46,66 +91,404 @@ fn grid_absolute_container_top_bottom_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 149f32, "height of node {:?}. Expected {}. Actual {}", node0, 149f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 149f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 149f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,6 +501,7 @@ fn grid_absolute_container_top_bottom_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -129,34 +513,70 @@ fn grid_absolute_container_top_bottom_margin__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -174,64 +594,402 @@ fn grid_absolute_container_top_bottom_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 149f32, "height of node {:?}. Expected {}. Actual {}", node0, 149f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 149f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 149f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_top_right.rs b/tests/generated/grid/grid_absolute_container_top_right.rs index 6a76a5312..9defa8657 100644 --- a/tests/generated/grid/grid_absolute_container_top_right.rs +++ b/tests/generated/grid/grid_absolute_container_top_right.rs @@ -7,22 +7,67 @@ fn grid_absolute_container_top_right__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -40,66 +85,398 @@ fn grid_absolute_container_top_right__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -112,39 +489,76 @@ fn grid_absolute_container_top_right__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -162,64 +576,396 @@ fn grid_absolute_container_top_right__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_container_top_right_margin.rs b/tests/generated/grid/grid_absolute_container_top_right_margin.rs index 05e1ec593..302dc955a 100644 --- a/tests/generated/grid/grid_absolute_container_top_right_margin.rs +++ b/tests/generated/grid/grid_absolute_container_top_right_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_container_top_right_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -17,18 +18,62 @@ fn grid_absolute_container_top_right_margin__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -46,66 +91,398 @@ fn grid_absolute_container_top_right_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 178f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 178f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,6 +495,7 @@ fn grid_absolute_container_top_right_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -129,34 +507,70 @@ fn grid_absolute_container_top_right_margin__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -174,64 +588,396 @@ fn grid_absolute_container_top_right_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 178f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 178f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_justify_self_sized_all.rs b/tests/generated/grid/grid_absolute_justify_self_sized_all.rs index 7442fc67f..e1ebd687e 100644 --- a/tests/generated/grid/grid_absolute_justify_self_sized_all.rs +++ b/tests/generated/grid/grid_absolute_justify_self_sized_all.rs @@ -7,6 +7,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -29,6 +31,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -40,6 +43,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -51,6 +55,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node4 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -62,6 +67,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node5 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -73,6 +79,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node6 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -84,6 +91,7 @@ fn grid_absolute_justify_self_sized_all__border_box() { let node7 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -96,6 +104,10 @@ fn grid_absolute_justify_self_sized_all__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -111,60 +123,359 @@ fn grid_absolute_justify_self_sized_all__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node5, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -177,6 +488,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -189,6 +501,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -201,6 +514,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -213,6 +527,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -225,6 +540,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -237,6 +553,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -249,6 +566,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -261,6 +579,7 @@ fn grid_absolute_justify_self_sized_all__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -274,6 +593,10 @@ fn grid_absolute_justify_self_sized_all__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -289,58 +612,357 @@ fn grid_absolute_justify_self_sized_all__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node5, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_layout_within_border.rs b/tests/generated/grid/grid_absolute_layout_within_border.rs index eef6e52b1..9b90db7f6 100644 --- a/tests/generated/grid/grid_absolute_layout_within_border.rs +++ b/tests/generated/grid/grid_absolute_layout_within_border.rs @@ -7,6 +7,7 @@ fn grid_absolute_layout_within_border__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,7 @@ fn grid_absolute_layout_within_border__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -29,6 +31,7 @@ fn grid_absolute_layout_within_border__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -46,6 +49,7 @@ fn grid_absolute_layout_within_border__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -64,6 +68,10 @@ fn grid_absolute_layout_within_border__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -89,36 +97,203 @@ fn grid_absolute_layout_within_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -131,6 +306,7 @@ fn grid_absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -143,6 +319,7 @@ fn grid_absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -155,6 +332,7 @@ fn grid_absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -173,6 +351,7 @@ fn grid_absolute_layout_within_border__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -192,6 +371,10 @@ fn grid_absolute_layout_within_border__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -217,34 +400,201 @@ fn grid_absolute_layout_within_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node3, 70f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_layout_within_border_static.rs b/tests/generated/grid/grid_absolute_layout_within_border_static.rs index b24fe0cf8..b1b64116e 100644 --- a/tests/generated/grid/grid_absolute_layout_within_border_static.rs +++ b/tests/generated/grid/grid_absolute_layout_within_border_static.rs @@ -7,6 +7,7 @@ fn grid_absolute_layout_within_border_static__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -19,6 +20,7 @@ fn grid_absolute_layout_within_border_static__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -31,6 +33,7 @@ fn grid_absolute_layout_within_border_static__border_box() { let node2 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -49,6 +52,7 @@ fn grid_absolute_layout_within_border_static__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -68,6 +72,10 @@ fn grid_absolute_layout_within_border_static__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -93,36 +101,203 @@ fn grid_absolute_layout_within_border_static__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -135,6 +310,7 @@ fn grid_absolute_layout_within_border_static__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -148,6 +324,7 @@ fn grid_absolute_layout_within_border_static__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -161,6 +338,7 @@ fn grid_absolute_layout_within_border_static__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -180,6 +358,7 @@ fn grid_absolute_layout_within_border_static__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -200,6 +379,10 @@ fn grid_absolute_layout_within_border_static__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -225,34 +408,201 @@ fn grid_absolute_layout_within_border_static__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 140f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node3, 70f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_overflow_clip.rs b/tests/generated/grid/grid_absolute_overflow_clip.rs new file mode 100644 index 000000000..644e4350d --- /dev/null +++ b/tests/generated/grid/grid_absolute_overflow_clip.rs @@ -0,0 +1,295 @@ +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_absolute_overflow_hidden.rs b/tests/generated/grid/grid_absolute_overflow_hidden.rs new file mode 100644 index 000000000..f13cc5968 --- /dev/null +++ b/tests/generated/grid/grid_absolute_overflow_hidden.rs @@ -0,0 +1,303 @@ +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_absolute_overflow_scroll.rs b/tests/generated/grid/grid_absolute_overflow_scroll.rs new file mode 100644 index 000000000..569f46ce9 --- /dev/null +++ b/tests/generated/grid/grid_absolute_overflow_scroll.rs @@ -0,0 +1,303 @@ +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 66f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 66f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 43f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 43f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 52f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 52f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_absolute_overflow_visible.rs b/tests/generated/grid/grid_absolute_overflow_visible.rs new file mode 100644 index 000000000..606730254 --- /dev/null +++ b/tests/generated/grid/grid_absolute_overflow_visible.rs @@ -0,0 +1,301 @@ +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 51f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 51f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_absolute_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + inset: taffy::geometry::Rect { + left: length(-10f32), + right: auto(), + top: length(-5f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 28f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 28f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 37f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 37f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != -3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -3f32, layout.location.x); + } + if layout.location.y != -4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), -4f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_absolute_resolved_insets.rs b/tests/generated/grid/grid_absolute_resolved_insets.rs index 930a8de1f..908d21ee8 100644 --- a/tests/generated/grid/grid_absolute_resolved_insets.rs +++ b/tests/generated/grid/grid_absolute_resolved_insets.rs @@ -7,6 +7,7 @@ fn grid_absolute_resolved_insets__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -19,6 +20,7 @@ fn grid_absolute_resolved_insets__border_box() { let node01 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -26,6 +28,7 @@ fn grid_absolute_resolved_insets__border_box() { let node02 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -33,6 +36,7 @@ fn grid_absolute_resolved_insets__border_box() { let node03 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -40,6 +44,7 @@ fn grid_absolute_resolved_insets__border_box() { let node04 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -47,6 +52,7 @@ fn grid_absolute_resolved_insets__border_box() { let node05 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -59,6 +65,10 @@ fn grid_absolute_resolved_insets__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -83,6 +93,7 @@ fn grid_absolute_resolved_insets__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -95,6 +106,7 @@ fn grid_absolute_resolved_insets__border_box() { let node11 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -102,6 +114,7 @@ fn grid_absolute_resolved_insets__border_box() { let node12 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -109,6 +122,7 @@ fn grid_absolute_resolved_insets__border_box() { let node13 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -116,6 +130,7 @@ fn grid_absolute_resolved_insets__border_box() { let node14 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -123,6 +138,7 @@ fn grid_absolute_resolved_insets__border_box() { let node15 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -161,119 +177,633 @@ fn grid_absolute_resolved_insets__border_box() { &[node10, node11, node12, node13, node14, node15], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node02, 180f32, location.x); - assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node02, 180f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 180f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node05, 160f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node05, 160f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 160f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); - assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 200f32, + layout.size.height + ); + } + if layout.location.x != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 200f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 165f32, "x of node {:?}. Expected {}. Actual {}", node12, 165f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node12, 165f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 165f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 145f32, "width of node {:?}. Expected {}. Actual {}", node15, 145f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node15, 145f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 145f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 145f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -286,6 +816,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -299,6 +830,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -307,6 +839,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -315,6 +848,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -323,6 +857,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -331,6 +866,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -344,6 +880,10 @@ fn grid_absolute_resolved_insets__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: taffy::style::Dimension::from_length(200f32), @@ -369,6 +909,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: auto(), @@ -382,6 +923,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(0f32), right: auto(), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -390,6 +932,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: percent(1f32), right: auto(), top: percent(1f32), bottom: auto() }, ..Default::default() }) @@ -398,6 +941,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: percent(1f32), top: auto(), bottom: percent(1f32) }, ..Default::default() }) @@ -406,6 +950,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(30f32), right: auto(), top: length(30f32), bottom: auto() }, ..Default::default() }) @@ -414,6 +959,7 @@ fn grid_absolute_resolved_insets__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(1f32), height: taffy::style::Dimension::from_percent(1f32), @@ -455,7 +1001,14 @@ fn grid_absolute_resolved_insets__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -463,112 +1016,615 @@ fn grid_absolute_resolved_insets__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 540f32, "width of node {:?}. Expected {}. Actual {}", node, 540f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 540f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 540f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 270f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node0, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node0, 270f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node02, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node02, 0f32, size.height); - assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node02, 250f32, location.x); - assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node02, 250f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 250f32, layout.location.x); + } + if layout.location.y != 250f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 250f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node03, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node03, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node03, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node04, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node04, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 230f32, "width of node {:?}. Expected {}. Actual {}", node05, 230f32, size.width); - assert_eq!(size.height, 230f32, "height of node {:?}. Expected {}. Actual {}", node05, 230f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node05, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node05, 20f32, location.y); + if layout.size.width != 230f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 230f32, layout.size.width); + } + if layout.size.height != 230f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 230f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 270f32, "width of node {:?}. Expected {}. Actual {}", node1, 270f32, size.width); - assert_eq!(size.height, 270f32, "height of node {:?}. Expected {}. Actual {}", node1, 270f32, size.height); - assert_eq!(location.x, 270f32, "x of node {:?}. Expected {}. Actual {}", node1, 270f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node1, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 270f32, layout.size.width); + } + if layout.size.height != 270f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 270f32, + layout.size.height + ); + } + if layout.location.x != 270f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 270f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node11, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node11, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node12, 0f32, size.height); - assert_eq!(location.x, 235f32, "x of node {:?}. Expected {}. Actual {}", node12, 235f32, location.x); - assert_eq!(location.y, 235f32, "y of node {:?}. Expected {}. Actual {}", node12, 235f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 235f32, layout.location.x); + } + if layout.location.y != 235f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 235f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node13, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node13, 0f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node13, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node14, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node14, 0f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node14, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node14, 50f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 215f32, "width of node {:?}. Expected {}. Actual {}", node15, 215f32, size.width); - assert_eq!(size.height, 215f32, "height of node {:?}. Expected {}. Actual {}", node15, 215f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node15, 20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node15, 20f32, location.y); + if layout.size.width != 215f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 215f32, layout.size.width); + } + if layout.size.height != 215f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 215f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_row_end.rs b/tests/generated/grid/grid_absolute_row_end.rs index 09340b190..f7fc44099 100644 --- a/tests/generated/grid/grid_absolute_row_end.rs +++ b/tests/generated/grid/grid_absolute_row_end.rs @@ -7,6 +7,7 @@ fn grid_absolute_row_end__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, inset: taffy::geometry::Rect { left: length(4f32), @@ -21,6 +22,10 @@ fn grid_absolute_row_end__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -38,18 +43,86 @@ fn grid_absolute_row_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 7f32, "height of node {:?}. Expected {}. Actual {}", node0, 7f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 7f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +135,7 @@ fn grid_absolute_row_end__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, inset: taffy::geometry::Rect { left: length(4f32), @@ -77,6 +151,10 @@ fn grid_absolute_row_end__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -94,16 +172,84 @@ fn grid_absolute_row_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 7f32, "height of node {:?}. Expected {}. Actual {}", node0, 7f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 7f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 7f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_row_start.rs b/tests/generated/grid/grid_absolute_row_start.rs index 38c6dbd92..db0625a22 100644 --- a/tests/generated/grid/grid_absolute_row_start.rs +++ b/tests/generated/grid/grid_absolute_row_start.rs @@ -7,6 +7,7 @@ fn grid_absolute_row_start__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, inset: taffy::geometry::Rect { left: length(4f32), @@ -21,6 +22,10 @@ fn grid_absolute_row_start__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -38,18 +43,92 @@ fn grid_absolute_row_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 147f32, "height of node {:?}. Expected {}. Actual {}", node0, 147f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 147f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 147f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +141,7 @@ fn grid_absolute_row_start__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, inset: taffy::geometry::Rect { left: length(4f32), @@ -77,6 +157,10 @@ fn grid_absolute_row_start__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -94,16 +178,90 @@ fn grid_absolute_row_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); - assert_eq!(size.height, 147f32, "height of node {:?}. Expected {}. Actual {}", node0, 147f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 173f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 173f32, layout.size.width); + } + if layout.size.height != 147f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 147f32, + layout.size.height + ); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_top_overrides_bottom.rs b/tests/generated/grid/grid_absolute_top_overrides_bottom.rs index abda6474c..f9c39a425 100644 --- a/tests/generated/grid/grid_absolute_top_overrides_bottom.rs +++ b/tests/generated/grid/grid_absolute_top_overrides_bottom.rs @@ -7,23 +7,68 @@ fn grid_absolute_top_overrides_bottom__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(2f32), bottom: length(5f32) }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -41,66 +86,398 @@ fn grid_absolute_top_overrides_bottom__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -113,40 +490,77 @@ fn grid_absolute_top_overrides_bottom__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(2f32), bottom: length(5f32) }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -164,64 +578,396 @@ fn grid_absolute_top_overrides_bottom__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_with_padding.rs b/tests/generated/grid/grid_absolute_with_padding.rs index 5a34948ee..3cf6e80c2 100644 --- a/tests/generated/grid/grid_absolute_with_padding.rs +++ b/tests/generated/grid/grid_absolute_with_padding.rs @@ -7,6 +7,7 @@ fn grid_absolute_with_padding__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -14,21 +15,61 @@ fn grid_absolute_with_padding__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: auto(), top: auto(), bottom: length(10f32) }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -46,66 +87,398 @@ fn grid_absolute_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node1, 150f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,6 +491,7 @@ fn grid_absolute_with_padding__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() }, ..Default::default() }) @@ -126,36 +500,69 @@ fn grid_absolute_with_padding__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, inset: taffy::geometry::Rect { left: length(10f32), right: auto(), top: auto(), bottom: length(10f32) }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -173,64 +580,396 @@ fn grid_absolute_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 180f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node1, 150f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_absolute_with_padding_and_margin.rs b/tests/generated/grid/grid_absolute_with_padding_and_margin.rs index 9e2e3433a..df2d3d587 100644 --- a/tests/generated/grid/grid_absolute_with_padding_and_margin.rs +++ b/tests/generated/grid/grid_absolute_with_padding_and_margin.rs @@ -7,6 +7,7 @@ fn grid_absolute_with_padding_and_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -20,6 +21,7 @@ fn grid_absolute_with_padding_and_margin__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -30,17 +32,56 @@ fn grid_absolute_with_padding_and_margin__border_box() { ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -58,66 +99,398 @@ fn grid_absolute_with_padding_and_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 178f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 178f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 14f32, "x of node {:?}. Expected {}. Actual {}", node1, 14f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node1, 147f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 14f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,6 +503,7 @@ fn grid_absolute_with_padding_and_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -144,6 +518,7 @@ fn grid_absolute_with_padding_and_margin__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, margin: taffy::geometry::Rect { left: length(4f32), right: length(2f32), @@ -155,31 +530,63 @@ fn grid_absolute_with_padding_and_margin__content_box() { }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -197,64 +604,396 @@ fn grid_absolute_with_padding_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 178f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 178f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 14f32, "x of node {:?}. Expected {}. Actual {}", node1, 14f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node1, 147f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 14f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_center.rs b/tests/generated/grid/grid_align_content_center.rs index cb0abbdb0..480d32fc6 100644 --- a/tests/generated/grid/grid_align_content_center.rs +++ b/tests/generated/grid/grid_align_content_center.rs @@ -4,19 +4,68 @@ fn grid_align_content_center__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_center__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_center_negative_space_gap.rs b/tests/generated/grid/grid_align_content_center_negative_space_gap.rs index a6d0470f8..acf8a1020 100644 --- a/tests/generated/grid/grid_align_content_center_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_center_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_center_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_center_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_center_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node00, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node01, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node03, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node04, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node05, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node06, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node07, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node08, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_center_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_center_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_center_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node00, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node01, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02, -10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node03, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node04, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node05, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node06, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node07, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node08, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_end.rs b/tests/generated/grid/grid_align_content_end.rs index f2fdc12fa..bd166aedb 100644 --- a/tests/generated/grid/grid_align_content_end.rs +++ b/tests/generated/grid/grid_align_content_end.rs @@ -4,19 +4,68 @@ fn grid_align_content_end__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node3, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node4, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_end__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node3, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node4, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_end_negative_space_gap.rs b/tests/generated/grid/grid_align_content_end_negative_space_gap.rs index 617a505b3..50a72561b 100644 --- a/tests/generated/grid/grid_align_content_end_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_end_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_end_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_end_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_end_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node00, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node01, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node02, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node03, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node04, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node05, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_end_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_end_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_end_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node00, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node01, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node02, -20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), -20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node03, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node04, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node05, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_end_with_padding_border.rs b/tests/generated/grid/grid_align_content_end_with_padding_border.rs index 1cc1e34ba..2cad8f7ef 100644 --- a/tests/generated/grid/grid_align_content_end_with_padding_border.rs +++ b/tests/generated/grid/grid_align_content_end_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_align_content_end_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_align_content_end_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node0, 44f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 44f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node1, 44f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 44f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node2, 44f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 44f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node3, 84f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 84f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 84f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node4, 84f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 84f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 84f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node5, 84f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 84f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 84f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node6, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node7, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node8, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_align_content_end_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_align_content_end_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node0, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node1, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node2, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 132f32, "y of node {:?}. Expected {}. Actual {}", node3, 132f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 132f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 132f32, "y of node {:?}. Expected {}. Actual {}", node4, 132f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 132f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 132f32, "y of node {:?}. Expected {}. Actual {}", node5, 132f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 132f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node6, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node7, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node8, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_around.rs b/tests/generated/grid/grid_align_content_space_around.rs index 90e8bfff4..ec2a9d478 100644 --- a/tests/generated/grid/grid_align_content_space_around.rs +++ b/tests/generated/grid/grid_align_content_space_around.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_around__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node2, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node6, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node7, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node8, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_space_around__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node2, 13f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node6, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node7, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node8, 147f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 147f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs b/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs index a0418ea69..991ed293d 100644 --- a/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_around_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_space_around_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_space_around_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_space_around_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_space_around_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_space_around_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs b/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs index 47d92ac5d..abe82adc2 100644 --- a/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs +++ b/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_around_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_align_content_space_around_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node0, 17f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 17f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node1, 17f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 17f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node2, 17f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 17f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 119f32, "y of node {:?}. Expected {}. Actual {}", node6, 119f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 119f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 119f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 119f32, "y of node {:?}. Expected {}. Actual {}", node7, 119f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 119f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 119f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 119f32, "y of node {:?}. Expected {}. Actual {}", node8, 119f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 119f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 119f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_align_content_space_around_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_align_content_space_around_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node1, 25f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node2, 25f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 25f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node3, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node4, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node5, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 159f32, "y of node {:?}. Expected {}. Actual {}", node6, 159f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 159f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 159f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 159f32, "y of node {:?}. Expected {}. Actual {}", node7, 159f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 159f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 159f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 159f32, "y of node {:?}. Expected {}. Actual {}", node8, 159f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 159f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 159f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_between.rs b/tests/generated/grid/grid_align_content_space_between.rs index ae341c6f1..d29b5e0c9 100644 --- a/tests/generated/grid/grid_align_content_space_between.rs +++ b/tests/generated/grid/grid_align_content_space_between.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_between__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_space_between__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs b/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs index 9899416e1..b57a14cc4 100644 --- a/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_between_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_space_between_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_space_between_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_space_between_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_space_between_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_space_between_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs b/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs index 74be09106..882702e0f 100644 --- a/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs +++ b/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_between_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_align_content_space_between_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node6, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node7, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node8, 124f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 124f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_align_content_space_between_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_align_content_space_between_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node3, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node4, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node5, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node6, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node7, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 172f32, "y of node {:?}. Expected {}. Actual {}", node8, 172f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 172f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 172f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_evenly.rs b/tests/generated/grid/grid_align_content_space_evenly.rs index fa841cc08..1f30d5fcb 100644 --- a/tests/generated/grid/grid_align_content_space_evenly.rs +++ b/tests/generated/grid/grid_align_content_space_evenly.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_evenly__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_space_evenly__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node6, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node8, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_space_evenly__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_space_evenly__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node6, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node8, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs b/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs index 9b388aff8..a8c85970c 100644 --- a/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_evenly_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_space_evenly_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_space_evenly_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_space_evenly_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceBetween), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_space_evenly_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_space_evenly_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs b/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs index 865b84e0d..726947f94 100644 --- a/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs +++ b/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_align_content_space_evenly_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_align_content_space_evenly_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 116f32, "y of node {:?}. Expected {}. Actual {}", node6, 116f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 116f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 116f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 116f32, "y of node {:?}. Expected {}. Actual {}", node7, 116f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 116f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 116f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 116f32, "y of node {:?}. Expected {}. Actual {}", node8, 116f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 116f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 116f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_align_content_space_evenly_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_align_content_space_evenly_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 32f32, "y of node {:?}. Expected {}. Actual {}", node0, 32f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 32f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 32f32, "y of node {:?}. Expected {}. Actual {}", node1, 32f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 32f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 32f32, "y of node {:?}. Expected {}. Actual {}", node2, 32f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 32f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node3, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node4, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node5, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 152f32, "y of node {:?}. Expected {}. Actual {}", node6, 152f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 152f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 152f32, "y of node {:?}. Expected {}. Actual {}", node7, 152f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 152f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 152f32, "y of node {:?}. Expected {}. Actual {}", node8, 152f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 152f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 152f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_start.rs b/tests/generated/grid/grid_align_content_start.rs index 5794695eb..917870779 100644 --- a/tests/generated/grid/grid_align_content_start.rs +++ b/tests/generated/grid/grid_align_content_start.rs @@ -4,19 +4,68 @@ fn grid_align_content_start__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_align_content_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_align_content_start__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_align_content_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_start_negative_space_gap.rs b/tests/generated/grid/grid_align_content_start_negative_space_gap.rs index 103581b35..d48ae9abb 100644 --- a/tests/generated/grid/grid_align_content_start_negative_space_gap.rs +++ b/tests/generated/grid/grid_align_content_start_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_align_content_start_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_align_content_start_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_align_content_start_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_align_content_start_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_align_content_start_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_align_content_start_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_content_start_with_padding_border.rs b/tests/generated/grid/grid_align_content_start_with_padding_border.rs index ee59f6670..6cebdb498 100644 --- a/tests/generated/grid/grid_align_content_start_with_padding_border.rs +++ b/tests/generated/grid/grid_align_content_start_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_align_content_start_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_align_content_start_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_align_content_start_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_align_content_start_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline.rs b/tests/generated/grid/grid_align_items_baseline.rs index 49d678320..f1dc824c3 100644 --- a/tests/generated/grid/grid_align_items_baseline.rs +++ b/tests/generated/grid/grid_align_items_baseline.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline__border_box() { let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -42,24 +48,125 @@ fn grid_align_items_baseline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,6 +179,7 @@ fn grid_align_items_baseline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -83,6 +191,7 @@ fn grid_align_items_baseline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -95,6 +204,10 @@ fn grid_align_items_baseline__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -109,22 +222,123 @@ fn grid_align_items_baseline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child.rs b/tests/generated/grid/grid_align_items_baseline_child.rs index cf6f62f1d..af011be91 100644 --- a/tests/generated/grid/grid_align_items_baseline_child.rs +++ b/tests/generated/grid/grid_align_items_baseline_child.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -41,6 +47,10 @@ fn grid_align_items_baseline_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -55,30 +65,170 @@ fn grid_align_items_baseline_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +241,7 @@ fn grid_align_items_baseline_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -102,6 +253,7 @@ fn grid_align_items_baseline_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -114,6 +266,10 @@ fn grid_align_items_baseline_child__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -128,6 +284,10 @@ fn grid_align_items_baseline_child__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -142,28 +302,168 @@ fn grid_align_items_baseline_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_margin.rs b/tests/generated/grid/grid_align_items_baseline_child_margin.rs index d4398a68e..9f4f78310 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_margin.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_margin.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_margin__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -23,6 +24,7 @@ fn grid_align_items_baseline_child_margin__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -40,6 +42,10 @@ fn grid_align_items_baseline_child_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -53,6 +59,10 @@ fn grid_align_items_baseline_child_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -67,30 +77,170 @@ fn grid_align_items_baseline_child_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,6 +253,7 @@ fn grid_align_items_baseline_child_margin__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -120,6 +271,7 @@ fn grid_align_items_baseline_child_margin__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +290,10 @@ fn grid_align_items_baseline_child_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -152,6 +308,10 @@ fn grid_align_items_baseline_child_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -166,28 +326,168 @@ fn grid_align_items_baseline_child_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_margin_percent.rs b/tests/generated/grid/grid_align_items_baseline_child_margin_percent.rs index 526b7b957..736948e26 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_margin_percent.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_margin_percent.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_margin_percent__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -23,6 +24,7 @@ fn grid_align_items_baseline_child_margin_percent__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -40,6 +42,10 @@ fn grid_align_items_baseline_child_margin_percent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -53,6 +59,10 @@ fn grid_align_items_baseline_child_margin_percent__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -67,30 +77,170 @@ fn grid_align_items_baseline_child_margin_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,6 +253,7 @@ fn grid_align_items_baseline_child_margin_percent__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -120,6 +271,7 @@ fn grid_align_items_baseline_child_margin_percent__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -138,6 +290,10 @@ fn grid_align_items_baseline_child_margin_percent__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -152,6 +308,10 @@ fn grid_align_items_baseline_child_margin_percent__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -166,28 +326,168 @@ fn grid_align_items_baseline_child_margin_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 1f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_multiline.rs b/tests/generated/grid/grid_align_items_baseline_child_multiline.rs index a47621acb..170545377 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_multiline.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_multiline.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_multiline__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child_multiline__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -27,6 +29,7 @@ fn grid_align_items_baseline_child_multiline__border_box() { let node11 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -37,6 +40,7 @@ fn grid_align_items_baseline_child_multiline__border_box() { let node12 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -47,6 +51,7 @@ fn grid_align_items_baseline_child_multiline__border_box() { let node13 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -59,6 +64,10 @@ fn grid_align_items_baseline_child_multiline__border_box() { taffy::style::Style { display: taffy::style::Display::Grid, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -70,6 +79,10 @@ fn grid_align_items_baseline_child_multiline__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -81,48 +94,305 @@ fn grid_align_items_baseline_child_multiline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -135,6 +405,7 @@ fn grid_align_items_baseline_child_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -146,6 +417,7 @@ fn grid_align_items_baseline_child_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -157,6 +429,7 @@ fn grid_align_items_baseline_child_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -168,6 +441,7 @@ fn grid_align_items_baseline_child_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -179,6 +453,7 @@ fn grid_align_items_baseline_child_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -192,6 +467,10 @@ fn grid_align_items_baseline_child_multiline__content_box() { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, flex_wrap: taffy::style::FlexWrap::Wrap, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -204,6 +483,10 @@ fn grid_align_items_baseline_child_multiline__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() @@ -215,46 +498,303 @@ fn grid_align_items_baseline_child_multiline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs b/tests/generated/grid/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs index 937f485ff..23a045cb1 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -27,6 +29,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b let node11 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -37,6 +40,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b let node12 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -47,6 +51,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b let node13 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -59,6 +64,10 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -73,6 +82,10 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -87,48 +100,305 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__border_b println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 8f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 8f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -141,6 +411,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -152,6 +423,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -163,6 +435,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(10f32), @@ -174,6 +447,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -185,6 +459,7 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -198,6 +473,10 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -213,6 +492,10 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -227,46 +510,303 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline__content_ println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 8f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 8f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_multiline_override.rs b/tests/generated/grid/grid_align_items_baseline_child_multiline_override.rs index 69df9f8cd..5f9c2388d 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_multiline_override.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_multiline_override.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -27,6 +29,7 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { let node11 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -38,6 +41,7 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { let node12 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -48,6 +52,7 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { let node13 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -60,6 +65,10 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -74,6 +83,10 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -88,48 +101,305 @@ fn grid_align_items_baseline_child_multiline_override__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 8f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 8f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -142,6 +412,7 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -153,6 +424,7 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -164,6 +436,7 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -176,6 +449,7 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), height: taffy::style::Dimension::from_length(20f32), @@ -187,6 +461,7 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(25f32), @@ -200,6 +475,10 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), @@ -215,6 +494,10 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -229,46 +512,303 @@ fn grid_align_items_baseline_child_multiline_override__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 8f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 8f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 68f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 15f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); - assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y); + if layout.size.width != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 25f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 25f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_padding.rs b/tests/generated/grid/grid_align_items_baseline_child_padding.rs index d2d3cc874..5c9ca75f5 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_padding.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_padding.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_padding__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child_padding__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_child_padding__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -47,6 +53,10 @@ fn grid_align_items_baseline_child_padding__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -67,30 +77,170 @@ fn grid_align_items_baseline_child_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 5f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 5f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,6 +253,7 @@ fn grid_align_items_baseline_child_padding__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -114,6 +265,7 @@ fn grid_align_items_baseline_child_padding__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -126,6 +278,10 @@ fn grid_align_items_baseline_child_padding__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -146,6 +302,10 @@ fn grid_align_items_baseline_child_padding__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -166,28 +326,168 @@ fn grid_align_items_baseline_child_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 110f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node10, 5f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_top.rs b/tests/generated/grid/grid_align_items_baseline_child_top.rs index adee38b87..aca4fa06d 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_top.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_top.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_top__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,7 @@ fn grid_align_items_baseline_child_top__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -29,6 +31,10 @@ fn grid_align_items_baseline_child_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +48,10 @@ fn grid_align_items_baseline_child_top__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -56,30 +66,170 @@ fn grid_align_items_baseline_child_top__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -92,6 +242,7 @@ fn grid_align_items_baseline_child_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,6 +255,7 @@ fn grid_align_items_baseline_child_top__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -116,6 +268,10 @@ fn grid_align_items_baseline_child_top__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -130,6 +286,10 @@ fn grid_align_items_baseline_child_top__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -144,28 +304,168 @@ fn grid_align_items_baseline_child_top__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_child_top2.rs b/tests/generated/grid/grid_align_items_baseline_child_top2.rs index e66abd071..ba006ce3e 100644 --- a/tests/generated/grid/grid_align_items_baseline_child_top2.rs +++ b/tests/generated/grid/grid_align_items_baseline_child_top2.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_child_top2__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_child_top2__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_child_top2__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -42,6 +48,10 @@ fn grid_align_items_baseline_child_top2__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -56,30 +66,170 @@ fn grid_align_items_baseline_child_top2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -92,6 +242,7 @@ fn grid_align_items_baseline_child_top2__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -103,6 +254,7 @@ fn grid_align_items_baseline_child_top2__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -115,6 +267,10 @@ fn grid_align_items_baseline_child_top2__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -130,6 +286,10 @@ fn grid_align_items_baseline_child_top2__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -144,28 +304,168 @@ fn grid_align_items_baseline_child_top2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_complex.rs b/tests/generated/grid/grid_align_items_baseline_complex.rs index a467d6e2f..e3fce926a 100644 --- a/tests/generated/grid/grid_align_items_baseline_complex.rs +++ b/tests/generated/grid/grid_align_items_baseline_complex.rs @@ -6,6 +6,7 @@ fn grid_align_items_baseline_complex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -15,6 +16,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node10 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -22,6 +24,10 @@ fn grid_align_items_baseline_complex__border_box() { let node1 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -33,6 +39,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node20 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -40,6 +47,10 @@ fn grid_align_items_baseline_complex__border_box() { let node2 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -51,6 +62,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -60,6 +72,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -69,6 +82,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -78,6 +92,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node60 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -85,6 +100,10 @@ fn grid_align_items_baseline_complex__border_box() { let node6 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -96,6 +115,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node70 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(5f32) }, ..Default::default() }) @@ -103,6 +123,10 @@ fn grid_align_items_baseline_complex__border_box() { let node7 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -114,6 +138,7 @@ fn grid_align_items_baseline_complex__border_box() { .unwrap(); let node8 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -125,6 +150,10 @@ fn grid_align_items_baseline_complex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -141,90 +170,572 @@ fn grid_align_items_baseline_complex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node20, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node60).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node60, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node60, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node60, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node60, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 95f32, "y of node {:?}. Expected {}. Actual {}", node7, 95f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 95f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node70).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node70, 0f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node70, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node70, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node70, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node70, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node70, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -236,6 +747,7 @@ fn grid_align_items_baseline_complex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -246,6 +758,7 @@ fn grid_align_items_baseline_complex__content_box() { let node10 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -254,6 +767,10 @@ fn grid_align_items_baseline_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -266,6 +783,7 @@ fn grid_align_items_baseline_complex__content_box() { let node20 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -274,6 +792,10 @@ fn grid_align_items_baseline_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -286,6 +808,7 @@ fn grid_align_items_baseline_complex__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -296,6 +819,7 @@ fn grid_align_items_baseline_complex__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -306,6 +830,7 @@ fn grid_align_items_baseline_complex__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -316,6 +841,7 @@ fn grid_align_items_baseline_complex__content_box() { let node60 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) }, ..Default::default() }) @@ -324,6 +850,10 @@ fn grid_align_items_baseline_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -336,6 +866,7 @@ fn grid_align_items_baseline_complex__content_box() { let node70 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(5f32) }, ..Default::default() }) @@ -344,6 +875,10 @@ fn grid_align_items_baseline_complex__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -356,6 +891,7 @@ fn grid_align_items_baseline_complex__content_box() { let node8 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -368,6 +904,10 @@ fn grid_align_items_baseline_complex__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -384,88 +924,570 @@ fn grid_align_items_baseline_complex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node20, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node60).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node60, 0f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node60, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node60, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node60, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node60, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node60, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 95f32, "y of node {:?}. Expected {}. Actual {}", node7, 95f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 95f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node70).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node70, 0f32, size.width); - assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node70, 5f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node70, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node70, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(size.height), 5f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node70, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node70, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node70, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_double_nested_child.rs b/tests/generated/grid/grid_align_items_baseline_double_nested_child.rs index 3445f29be..fb8d2a2ab 100644 --- a/tests/generated/grid/grid_align_items_baseline_double_nested_child.rs +++ b/tests/generated/grid/grid_align_items_baseline_double_nested_child.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_double_nested_child__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -18,6 +19,10 @@ fn grid_align_items_baseline_double_nested_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -30,6 +35,7 @@ fn grid_align_items_baseline_double_nested_child__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -41,6 +47,10 @@ fn grid_align_items_baseline_double_nested_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -54,6 +64,10 @@ fn grid_align_items_baseline_double_nested_child__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -68,36 +82,215 @@ fn grid_align_items_baseline_double_nested_child__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -110,6 +303,7 @@ fn grid_align_items_baseline_double_nested_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -122,6 +316,10 @@ fn grid_align_items_baseline_double_nested_child__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -135,6 +333,7 @@ fn grid_align_items_baseline_double_nested_child__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(15f32), @@ -147,6 +346,10 @@ fn grid_align_items_baseline_double_nested_child__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -161,6 +364,10 @@ fn grid_align_items_baseline_double_nested_child__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -175,34 +382,213 @@ fn grid_align_items_baseline_double_nested_child__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 65f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 15f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 15f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_multiline.rs b/tests/generated/grid/grid_align_items_baseline_multiline.rs index 597b1fc65..b414d08fe 100644 --- a/tests/generated/grid/grid_align_items_baseline_multiline.rs +++ b/tests/generated/grid/grid_align_items_baseline_multiline.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_multiline__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_multiline__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -40,6 +46,7 @@ fn grid_align_items_baseline_multiline__border_box() { let node20 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +58,10 @@ fn grid_align_items_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -63,6 +74,7 @@ fn grid_align_items_baseline_multiline__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -74,6 +86,10 @@ fn grid_align_items_baseline_multiline__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -89,48 +105,293 @@ fn grid_align_items_baseline_multiline__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,6 +404,7 @@ fn grid_align_items_baseline_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -154,6 +416,7 @@ fn grid_align_items_baseline_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +429,10 @@ fn grid_align_items_baseline_multiline__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -179,6 +446,7 @@ fn grid_align_items_baseline_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +459,10 @@ fn grid_align_items_baseline_multiline__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -204,6 +476,7 @@ fn grid_align_items_baseline_multiline__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -216,6 +489,10 @@ fn grid_align_items_baseline_multiline__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -231,46 +508,291 @@ fn grid_align_items_baseline_multiline__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_multiline_column.rs b/tests/generated/grid/grid_align_items_baseline_multiline_column.rs index eac61a600..03b8d5e5c 100644 --- a/tests/generated/grid/grid_align_items_baseline_multiline_column.rs +++ b/tests/generated/grid/grid_align_items_baseline_multiline_column.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_multiline_column__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_multiline_column__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_multiline_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -40,6 +46,7 @@ fn grid_align_items_baseline_multiline_column__border_box() { let node20 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +58,10 @@ fn grid_align_items_baseline_multiline_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -63,6 +74,7 @@ fn grid_align_items_baseline_multiline_column__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -74,6 +86,10 @@ fn grid_align_items_baseline_multiline_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -89,48 +105,293 @@ fn grid_align_items_baseline_multiline_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 60f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,6 +404,7 @@ fn grid_align_items_baseline_multiline_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -154,6 +416,7 @@ fn grid_align_items_baseline_multiline_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -166,6 +429,10 @@ fn grid_align_items_baseline_multiline_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: taffy::style::Dimension::from_length(50f32), @@ -179,6 +446,7 @@ fn grid_align_items_baseline_multiline_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +459,10 @@ fn grid_align_items_baseline_multiline_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: taffy::style::Dimension::from_length(70f32), @@ -204,6 +476,7 @@ fn grid_align_items_baseline_multiline_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -216,6 +489,10 @@ fn grid_align_items_baseline_multiline_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -231,46 +508,291 @@ fn grid_align_items_baseline_multiline_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 60f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 70f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_multiline_row_and_column.rs b/tests/generated/grid/grid_align_items_baseline_multiline_row_and_column.rs index 5277890b5..321fb2e1b 100644 --- a/tests/generated/grid/grid_align_items_baseline_multiline_row_and_column.rs +++ b/tests/generated/grid/grid_align_items_baseline_multiline_row_and_column.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { let node10 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -28,6 +30,10 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -40,6 +46,7 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { let node20 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -51,6 +58,10 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -63,6 +74,7 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { let node3 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -74,6 +86,10 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -89,48 +105,293 @@ fn grid_align_items_baseline_multiline_row_and_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,6 +404,7 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -154,6 +416,7 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -166,6 +429,10 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -179,6 +446,7 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(10f32), @@ -191,6 +459,10 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -204,6 +476,7 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(20f32), @@ -216,6 +489,10 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { @@ -231,46 +508,291 @@ fn grid_align_items_baseline_multiline_row_and_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node20).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node20, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node20, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_baseline_nested_column.rs b/tests/generated/grid/grid_align_items_baseline_nested_column.rs index 8a226cdc8..e13a07f9e 100644 --- a/tests/generated/grid/grid_align_items_baseline_nested_column.rs +++ b/tests/generated/grid/grid_align_items_baseline_nested_column.rs @@ -7,6 +7,7 @@ fn grid_align_items_baseline_nested_column__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -17,6 +18,7 @@ fn grid_align_items_baseline_nested_column__border_box() { let node100 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(30f32), @@ -27,6 +29,7 @@ fn grid_align_items_baseline_nested_column__border_box() { let node101 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(40f32), @@ -38,6 +41,10 @@ fn grid_align_items_baseline_nested_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(80f32), @@ -49,7 +56,14 @@ fn grid_align_items_baseline_nested_column__border_box() { .unwrap(); let node1 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node10], ) .unwrap(); @@ -57,6 +71,10 @@ fn grid_align_items_baseline_nested_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -71,42 +89,260 @@ fn grid_align_items_baseline_nested_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node101, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -119,6 +355,7 @@ fn grid_align_items_baseline_nested_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(60f32), @@ -130,6 +367,7 @@ fn grid_align_items_baseline_nested_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(30f32), @@ -141,6 +379,7 @@ fn grid_align_items_baseline_nested_column__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(40f32), @@ -153,6 +392,10 @@ fn grid_align_items_baseline_nested_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(80f32), @@ -167,6 +410,10 @@ fn grid_align_items_baseline_nested_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node10], @@ -177,6 +424,10 @@ fn grid_align_items_baseline_nested_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), @@ -191,40 +442,258 @@ fn grid_align_items_baseline_nested_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 80f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(size.height), + 30f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node100, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); - assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node101, 35f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node101, stringify!(location.y), 35f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_sized_center.rs b/tests/generated/grid/grid_align_items_sized_center.rs index 776f9e501..59b4b3d92 100644 --- a/tests/generated/grid/grid_align_items_sized_center.rs +++ b/tests/generated/grid/grid_align_items_sized_center.rs @@ -6,6 +6,7 @@ fn grid_align_items_sized_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_align_items_sized_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_align_items_sized_center__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_align_items_sized_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_align_items_sized_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_align_items_sized_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_align_items_sized_center__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_align_items_sized_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 70f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_sized_end.rs b/tests/generated/grid/grid_align_items_sized_end.rs index ecfbfc29e..9e6ca4c7b 100644 --- a/tests/generated/grid/grid_align_items_sized_end.rs +++ b/tests/generated/grid/grid_align_items_sized_end.rs @@ -6,6 +6,7 @@ fn grid_align_items_sized_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_align_items_sized_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_align_items_sized_end__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_align_items_sized_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_align_items_sized_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_align_items_sized_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_align_items_sized_end__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_align_items_sized_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_sized_start.rs b/tests/generated/grid/grid_align_items_sized_start.rs index f2fc9ea50..da9ad646b 100644 --- a/tests/generated/grid/grid_align_items_sized_start.rs +++ b/tests/generated/grid/grid_align_items_sized_start.rs @@ -6,6 +6,7 @@ fn grid_align_items_sized_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_align_items_sized_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_align_items_sized_start__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_align_items_sized_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_align_items_sized_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_align_items_sized_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_align_items_sized_start__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_align_items_sized_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_items_sized_stretch.rs b/tests/generated/grid/grid_align_items_sized_stretch.rs index b66e481fa..054a5ba7b 100644 --- a/tests/generated/grid/grid_align_items_sized_stretch.rs +++ b/tests/generated/grid/grid_align_items_sized_stretch.rs @@ -6,6 +6,7 @@ fn grid_align_items_sized_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_align_items_sized_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_align_items_sized_stretch__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_align_items_sized_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_align_items_sized_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_align_items_sized_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_align_items_sized_stretch__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_items: Some(taffy::style::AlignItems::Stretch), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_align_items_sized_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_align_self_sized_all.rs b/tests/generated/grid/grid_align_self_sized_all.rs index 86388b4ff..f286a3263 100644 --- a/tests/generated/grid/grid_align_self_sized_all.rs +++ b/tests/generated/grid/grid_align_self_sized_all.rs @@ -6,6 +6,7 @@ fn grid_align_self_sized_all__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -26,6 +28,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -36,6 +39,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -46,6 +50,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -56,6 +61,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -66,6 +72,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -76,6 +83,7 @@ fn grid_align_self_sized_all__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -88,6 +96,10 @@ fn grid_align_self_sized_all__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -103,60 +115,359 @@ fn grid_align_self_sized_all__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -168,6 +479,7 @@ fn grid_align_self_sized_all__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -179,6 +491,7 @@ fn grid_align_self_sized_all__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -190,6 +503,7 @@ fn grid_align_self_sized_all__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -201,6 +515,7 @@ fn grid_align_self_sized_all__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -212,6 +527,7 @@ fn grid_align_self_sized_all__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -223,6 +539,7 @@ fn grid_align_self_sized_all__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -234,6 +551,7 @@ fn grid_align_self_sized_all__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -245,6 +563,7 @@ fn grid_align_self_sized_all__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -258,6 +577,10 @@ fn grid_align_self_sized_all__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -273,58 +596,357 @@ fn grid_align_self_sized_all__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/grid/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs index fb390e47d..0d8074256 100644 --- a/tests/generated/grid/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/grid/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs @@ -7,6 +7,7 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__borde let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -21,6 +22,10 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__borde .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__borde println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__conte .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.05f32), @@ -73,6 +153,10 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__conte taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset__conte println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_absolute_fill_height_from_inset.rs b/tests/generated/grid/grid_aspect_ratio_absolute_fill_height_from_inset.rs index 2606adaa5..c8f07cc47 100644 --- a/tests/generated/grid/grid_aspect_ratio_absolute_fill_height_from_inset.rs +++ b/tests/generated/grid/grid_aspect_ratio_absolute_fill_height_from_inset.rs @@ -7,6 +7,7 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -21,6 +22,10 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -34,18 +39,92 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +137,7 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: percent(0.1f32), @@ -73,6 +153,10 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -86,16 +170,90 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 107f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 107f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_absolute_fill_width_from_inset.rs b/tests/generated/grid/grid_aspect_ratio_absolute_fill_width_from_inset.rs index dbb53daf6..3d00318fa 100644 --- a/tests/generated/grid/grid_aspect_ratio_absolute_fill_width_from_inset.rs +++ b/tests/generated/grid/grid_aspect_ratio_absolute_fill_width_from_inset.rs @@ -7,6 +7,7 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -16,6 +17,10 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -29,18 +34,86 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, ..Default::default() @@ -63,6 +137,10 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -76,16 +154,84 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_absolute_height_overrides_inset.rs b/tests/generated/grid/grid_aspect_ratio_absolute_height_overrides_inset.rs index 3962fef49..387a58176 100644 --- a/tests/generated/grid/grid_aspect_ratio_absolute_height_overrides_inset.rs +++ b/tests/generated/grid/grid_aspect_ratio_absolute_height_overrides_inset.rs @@ -7,6 +7,7 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -17,6 +18,10 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -30,18 +35,86 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_percent(0.1f32) }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { left: auto(), right: auto(), top: percent(0.3f32), bottom: percent(0.5f32) }, @@ -65,6 +139,10 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -78,16 +156,84 @@ fn grid_aspect_ratio_absolute_height_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_absolute_width_overrides_inset.rs b/tests/generated/grid/grid_aspect_ratio_absolute_width_overrides_inset.rs index 62d6813e5..a3f9f7fa6 100644 --- a/tests/generated/grid/grid_aspect_ratio_absolute_width_overrides_inset.rs +++ b/tests/generated/grid/grid_aspect_ratio_absolute_width_overrides_inset.rs @@ -7,6 +7,7 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__border_box() { let node0 = taffy .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -22,6 +23,10 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -35,18 +40,86 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -59,6 +132,7 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__content_box() { .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, position: taffy::style::Position::Absolute, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.4f32), height: auto() }, aspect_ratio: Some(3f32), inset: taffy::geometry::Rect { @@ -75,6 +149,10 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: taffy::style::Dimension::from_length(300f32), @@ -88,16 +166,84 @@ fn grid_aspect_ratio_absolute_width_overrides_inset__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 400f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 400f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 53f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 53f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_child_fill_content_height.rs b/tests/generated/grid/grid_aspect_ratio_child_fill_content_height.rs index 00c737d70..e2539f6dc 100644 --- a/tests/generated/grid/grid_aspect_ratio_child_fill_content_height.rs +++ b/tests/generated/grid/grid_aspect_ratio_child_fill_content_height.rs @@ -6,19 +6,34 @@ fn grid_aspect_ratio_child_fill_content_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -26,24 +41,125 @@ fn grid_aspect_ratio_child_fill_content_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +172,10 @@ fn grid_aspect_ratio_child_fill_content_height__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, aspect_ratio: Some(0.5f32), ..Default::default() }, @@ -65,6 +185,7 @@ fn grid_aspect_ratio_child_fill_content_height__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) @@ -74,6 +195,10 @@ fn grid_aspect_ratio_child_fill_content_height__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -83,22 +208,123 @@ fn grid_aspect_ratio_child_fill_content_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_child_fill_content_width.rs b/tests/generated/grid/grid_aspect_ratio_child_fill_content_width.rs index 91ee8cb30..a58b838b2 100644 --- a/tests/generated/grid/grid_aspect_ratio_child_fill_content_width.rs +++ b/tests/generated/grid/grid_aspect_ratio_child_fill_content_width.rs @@ -6,19 +6,34 @@ fn grid_aspect_ratio_child_fill_content_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { aspect_ratio: Some(2f32), ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + aspect_ratio: Some(2f32), + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0, node1], ) .unwrap(); @@ -26,24 +41,125 @@ fn grid_aspect_ratio_child_fill_content_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +172,10 @@ fn grid_aspect_ratio_child_fill_content_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, aspect_ratio: Some(2f32), ..Default::default() }, @@ -65,6 +185,7 @@ fn grid_aspect_ratio_child_fill_content_width__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, ..Default::default() }) @@ -74,6 +195,10 @@ fn grid_aspect_ratio_child_fill_content_width__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0, node1], @@ -83,22 +208,123 @@ fn grid_aspect_ratio_child_fill_content_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_fill_child_height.rs b/tests/generated/grid/grid_aspect_ratio_fill_child_height.rs index eeace1b48..c3cce932f 100644 --- a/tests/generated/grid/grid_aspect_ratio_fill_child_height.rs +++ b/tests/generated/grid/grid_aspect_ratio_fill_child_height.rs @@ -6,6 +6,7 @@ fn grid_aspect_ratio_fill_child_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn grid_aspect_ratio_fill_child_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn grid_aspect_ratio_fill_child_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node0, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn grid_aspect_ratio_fill_child_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -61,6 +135,10 @@ fn grid_aspect_ratio_fill_child_height__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn grid_aspect_ratio_fill_child_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node0, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_fill_child_max_height.rs b/tests/generated/grid/grid_aspect_ratio_fill_child_max_height.rs index 54b6a2f7c..ea10e77af 100644 --- a/tests/generated/grid/grid_aspect_ratio_fill_child_max_height.rs +++ b/tests/generated/grid/grid_aspect_ratio_fill_child_max_height.rs @@ -7,6 +7,10 @@ fn grid_aspect_ratio_fill_child_max_height__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -21,6 +25,10 @@ fn grid_aspect_ratio_fill_child_max_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -34,18 +42,86 @@ fn grid_aspect_ratio_fill_child_max_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -58,6 +134,10 @@ fn grid_aspect_ratio_fill_child_max_height__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -73,6 +153,10 @@ fn grid_aspect_ratio_fill_child_max_height__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -86,16 +170,84 @@ fn grid_aspect_ratio_fill_child_max_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_fill_child_max_width.rs b/tests/generated/grid/grid_aspect_ratio_fill_child_max_width.rs index 74d2cba42..24689e86d 100644 --- a/tests/generated/grid/grid_aspect_ratio_fill_child_max_width.rs +++ b/tests/generated/grid/grid_aspect_ratio_fill_child_max_width.rs @@ -7,6 +7,10 @@ fn grid_aspect_ratio_fill_child_max_width__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -18,6 +22,10 @@ fn grid_aspect_ratio_fill_child_max_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +39,86 @@ fn grid_aspect_ratio_fill_child_max_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +131,10 @@ fn grid_aspect_ratio_fill_child_max_width__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -67,6 +147,10 @@ fn grid_aspect_ratio_fill_child_max_width__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +164,84 @@ fn grid_aspect_ratio_fill_child_max_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_fill_child_min_height.rs b/tests/generated/grid/grid_aspect_ratio_fill_child_min_height.rs index 82248e9c4..ad408604c 100644 --- a/tests/generated/grid/grid_aspect_ratio_fill_child_min_height.rs +++ b/tests/generated/grid/grid_aspect_ratio_fill_child_min_height.rs @@ -6,6 +6,7 @@ fn grid_aspect_ratio_fill_child_min_height__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn grid_aspect_ratio_fill_child_min_height__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn grid_aspect_ratio_fill_child_min_height__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn grid_aspect_ratio_fill_child_min_height__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, aspect_ratio: Some(2f32), ..Default::default() @@ -61,6 +135,10 @@ fn grid_aspect_ratio_fill_child_min_height__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn grid_aspect_ratio_fill_child_min_height__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_fill_child_width.rs b/tests/generated/grid/grid_aspect_ratio_fill_child_width.rs index bc1edc250..82def5f67 100644 --- a/tests/generated/grid/grid_aspect_ratio_fill_child_width.rs +++ b/tests/generated/grid/grid_aspect_ratio_fill_child_width.rs @@ -6,6 +6,7 @@ fn grid_aspect_ratio_fill_child_width__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -15,6 +16,10 @@ fn grid_aspect_ratio_fill_child_width__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -28,18 +33,86 @@ fn grid_aspect_ratio_fill_child_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -51,6 +124,7 @@ fn grid_aspect_ratio_fill_child_width__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) }, aspect_ratio: Some(2f32), ..Default::default() @@ -61,6 +135,10 @@ fn grid_aspect_ratio_fill_child_width__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -74,16 +152,84 @@ fn grid_aspect_ratio_fill_child_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes.rs b/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes.rs index 35aca16ba..6b6adc478 100644 --- a/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes.rs +++ b/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes.rs @@ -6,6 +6,7 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,10 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -67,6 +141,10 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes_flex.rs b/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes_flex.rs index 4e444c77c..ddb4e5170 100644 --- a/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes_flex.rs +++ b/tests/generated/grid/grid_aspect_ratio_overridden_by_explicit_sizes_flex.rs @@ -6,6 +6,7 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -18,6 +19,10 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -31,18 +36,86 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -54,6 +127,7 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -67,6 +141,10 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -80,16 +158,84 @@ fn grid_aspect_ratio_overridden_by_explicit_sizes_flex__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_columns.rs b/tests/generated/grid/grid_auto_columns.rs index 060b9c578..d13998b09 100644 --- a/tests/generated/grid/grid_auto_columns.rs +++ b/tests/generated/grid/grid_auto_columns.rs @@ -6,21 +6,61 @@ fn grid_auto_columns__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(-3i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(100f32)], grid_template_columns: vec![length(40f32)], grid_auto_columns: vec![length(10f32), length(20f32), length(30f32)], @@ -34,60 +74,407 @@ fn grid_auto_columns__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node, 190f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node5, 100f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node5, 130f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node6, 100f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node6, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node7, 100f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node7, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,36 +486,69 @@ fn grid_auto_columns__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(-3i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(100f32)], grid_template_columns: vec![length(40f32)], grid_auto_columns: vec![length(10f32), length(20f32), length(30f32)], @@ -142,58 +562,405 @@ fn grid_auto_columns__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node, 190f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node5, 100f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node5, 130f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node6, 100f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node6, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node7, 100f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node7, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_columns_fixed_width.rs b/tests/generated/grid/grid_auto_columns_fixed_width.rs index 4df554c98..b63ca6013 100644 --- a/tests/generated/grid/grid_auto_columns_fixed_width.rs +++ b/tests/generated/grid/grid_auto_columns_fixed_width.rs @@ -4,26 +4,110 @@ fn grid_auto_columns_fixed_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node14 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node15 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node11 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node12 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node13 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node14 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node15 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), auto(), length(40f32), auto()], grid_template_columns: vec![length(40f32), auto(), length(40f32), auto()], size: taffy::geometry::Size { @@ -42,108 +126,707 @@ fn grid_auto_columns_fixed_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node3, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node6, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node7, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node8, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node9, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node9, 40f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node9, 100f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node10, 100f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node10, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node11, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node11, 140f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node11, 100f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node12, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node12, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node13, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node13, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node13, 140f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node14, 60f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node14, 100f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node14, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node15, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node15, 60f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node15, 140f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node15, 140f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -153,58 +836,126 @@ fn grid_auto_columns_fixed_width__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node9 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node11 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node12 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node13 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node14 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node15 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), auto(), length(40f32), auto()], grid_template_columns: vec![length(40f32), auto(), length(40f32), auto()], size: taffy::geometry::Size { @@ -223,106 +974,705 @@ fn grid_auto_columns_fixed_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node3, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node6, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node7, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node8, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node9, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node9, 40f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node9, 100f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node10, 100f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node10, 100f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node11, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node11, 140f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node11, 100f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node12, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node12, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node13, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node13, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node13, 140f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node14).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node14, 60f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node14, 100f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node14, 140f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node14, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node14, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node15).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node15, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node15, 60f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node15, 140f32, location.x); - assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node15, 140f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(size.height), + 60f32, + layout.size.height + ); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node15, stringify!(location.y), 140f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node15, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_fill_fixed_size.rs b/tests/generated/grid/grid_auto_fill_fixed_size.rs index a43e8de44..0c06fb7d1 100644 --- a/tests/generated/grid/grid_auto_fill_fixed_size.rs +++ b/tests/generated/grid/grid_auto_fill_fixed_size.rs @@ -4,19 +4,68 @@ fn grid_auto_fill_fixed_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), repeat(RepetitionCount::AutoFill, vec![length(40f32)])], size: taffy::geometry::Size { @@ -32,66 +81,398 @@ fn grid_auto_fill_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,37 +482,77 @@ fn grid_auto_fill_fixed_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), repeat(RepetitionCount::AutoFill, vec![length(40f32)])], size: taffy::geometry::Size { @@ -147,64 +568,396 @@ fn grid_auto_fill_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_fill_with_empty_auto_track.rs b/tests/generated/grid/grid_auto_fill_with_empty_auto_track.rs index cdb7d6134..67abcc815 100644 --- a/tests/generated/grid/grid_auto_fill_with_empty_auto_track.rs +++ b/tests/generated/grid/grid_auto_fill_with_empty_auto_track.rs @@ -4,12 +4,26 @@ fn grid_auto_fill_with_empty_auto_track__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![repeat(RepetitionCount::AutoFill, vec![length(40f32)])], @@ -26,24 +40,125 @@ fn grid_auto_fill_with_empty_auto_track__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,16 +168,28 @@ fn grid_auto_fill_with_empty_auto_track__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![repeat(RepetitionCount::AutoFill, vec![length(40f32)])], @@ -79,22 +206,123 @@ fn grid_auto_fill_with_empty_auto_track__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_fit_definite_percentage.rs b/tests/generated/grid/grid_auto_fit_definite_percentage.rs index 30620ea07..ad285e5e0 100644 --- a/tests/generated/grid/grid_auto_fit_definite_percentage.rs +++ b/tests/generated/grid/grid_auto_fit_definite_percentage.rs @@ -4,26 +4,70 @@ fn grid_auto_fit_definite_percentage__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node01 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node02 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node03 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node04 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node05 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node06 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node07 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, grid_template_columns: vec![repeat(RepetitionCount::AutoFill, vec![minmax(length(150f32), fr(1f32))])], size: taffy::geometry::Size { @@ -44,6 +88,10 @@ fn grid_auto_fit_definite_percentage__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(730f32), height: taffy::style::Dimension::from_length(300f32), @@ -57,66 +105,452 @@ fn grid_auto_fit_definite_percentage__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 730f32, "width of node {:?}. Expected {}. Actual {}", node, 730f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 730f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 730f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 730f32, "width of node {:?}. Expected {}. Actual {}", node0, 730f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node0, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 730f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 730f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 300f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node00, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node00, 135f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node01, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node01, 135f32, size.height); - assert_eq!(location.x, 190f32, "x of node {:?}. Expected {}. Actual {}", node01, 190f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 190f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node02, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node02, 135f32, size.height); - assert_eq!(location.x, 370f32, "x of node {:?}. Expected {}. Actual {}", node02, 370f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 370f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 370f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node03, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node03, 135f32, size.height); - assert_eq!(location.x, 550f32, "x of node {:?}. Expected {}. Actual {}", node03, 550f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 550f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 550f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node04, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node04, 135f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node04, 10f32, location.x); - assert_eq!(location.y, 155f32, "y of node {:?}. Expected {}. Actual {}", node04, 155f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 155f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 155f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node05, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node05, 135f32, size.height); - assert_eq!(location.x, 190f32, "x of node {:?}. Expected {}. Actual {}", node05, 190f32, location.x); - assert_eq!(location.y, 155f32, "y of node {:?}. Expected {}. Actual {}", node05, 155f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 190f32, layout.location.x); + } + if layout.location.y != 155f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 155f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node06, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node06, 135f32, size.height); - assert_eq!(location.x, 370f32, "x of node {:?}. Expected {}. Actual {}", node06, 370f32, location.x); - assert_eq!(location.y, 155f32, "y of node {:?}. Expected {}. Actual {}", node06, 155f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 370f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 370f32, layout.location.x); + } + if layout.location.y != 155f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 155f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node07, 170f32, size.width); - assert_eq!(size.height, 135f32, "height of node {:?}. Expected {}. Actual {}", node07, 135f32, size.height); - assert_eq!(location.x, 550f32, "x of node {:?}. Expected {}. Actual {}", node07, 550f32, location.x); - assert_eq!(location.y, 155f32, "y of node {:?}. Expected {}. Actual {}", node07, 155f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 135f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 135f32, + layout.size.height + ); + } + if layout.location.x != 550f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 550f32, layout.location.x); + } + if layout.location.y != 155f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 155f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +563,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -136,6 +571,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -143,6 +579,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -150,6 +587,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -157,6 +595,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -164,6 +603,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -171,6 +611,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -178,6 +619,7 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); @@ -186,6 +628,10 @@ fn grid_auto_fit_definite_percentage__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, grid_template_columns: vec![repeat(RepetitionCount::AutoFill, vec![minmax(length(150f32), fr(1f32))])], size: taffy::geometry::Size { @@ -207,6 +653,10 @@ fn grid_auto_fit_definite_percentage__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(730f32), height: taffy::style::Dimension::from_length(300f32), @@ -220,64 +670,450 @@ fn grid_auto_fit_definite_percentage__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 730f32, "width of node {:?}. Expected {}. Actual {}", node, 730f32, size.width); - assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 730f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 730f32, layout.size.width); + } + if layout.size.height != 300f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 300f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 730f32, "width of node {:?}. Expected {}. Actual {}", node0, 730f32, size.width); - assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 730f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 730f32, layout.size.width); + } + if layout.size.height != 320f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 320f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node00, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node00, 145f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node01, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node01, 145f32, size.height); - assert_eq!(location.x, 190f32, "x of node {:?}. Expected {}. Actual {}", node01, 190f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 190f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node02, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node02, 145f32, size.height); - assert_eq!(location.x, 370f32, "x of node {:?}. Expected {}. Actual {}", node02, 370f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 370f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 370f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node03, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node03, 145f32, size.height); - assert_eq!(location.x, 550f32, "x of node {:?}. Expected {}. Actual {}", node03, 550f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 550f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 550f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node04, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node04, 145f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node04, 10f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node04, 165f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node05, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node05, 145f32, size.height); - assert_eq!(location.x, 190f32, "x of node {:?}. Expected {}. Actual {}", node05, 190f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node05, 165f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 190f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node06, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node06, 145f32, size.height); - assert_eq!(location.x, 370f32, "x of node {:?}. Expected {}. Actual {}", node06, 370f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node06, 165f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 370f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 370f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 170f32, "width of node {:?}. Expected {}. Actual {}", node07, 170f32, size.width); - assert_eq!(size.height, 145f32, "height of node {:?}. Expected {}. Actual {}", node07, 145f32, size.height); - assert_eq!(location.x, 550f32, "x of node {:?}. Expected {}. Actual {}", node07, 550f32, location.x); - assert_eq!(location.y, 165f32, "y of node {:?}. Expected {}. Actual {}", node07, 165f32, location.y); + if layout.size.width != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 170f32, layout.size.width); + } + if layout.size.height != 145f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 145f32, + layout.size.height + ); + } + if layout.location.x != 550f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 550f32, layout.location.x); + } + if layout.location.y != 165f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 165f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_fit_with_empty_auto_track.rs b/tests/generated/grid/grid_auto_fit_with_empty_auto_track.rs index 438eba302..b0be00c3e 100644 --- a/tests/generated/grid/grid_auto_fit_with_empty_auto_track.rs +++ b/tests/generated/grid/grid_auto_fit_with_empty_auto_track.rs @@ -4,12 +4,26 @@ fn grid_auto_fit_with_empty_auto_track__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![repeat(RepetitionCount::AutoFit, vec![length(40f32)])], @@ -26,24 +40,125 @@ fn grid_auto_fit_with_empty_auto_track__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,16 +168,28 @@ fn grid_auto_fit_with_empty_auto_track__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![repeat(RepetitionCount::AutoFit, vec![length(40f32)])], @@ -79,22 +206,123 @@ fn grid_auto_fit_with_empty_auto_track__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 67f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_rows.rs b/tests/generated/grid/grid_auto_rows.rs index 0f4818d5c..c5421dd24 100644 --- a/tests/generated/grid/grid_auto_rows.rs +++ b/tests/generated/grid/grid_auto_rows.rs @@ -6,21 +6,61 @@ fn grid_auto_rows__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![length(100f32)], grid_auto_rows: vec![length(10f32), length(20f32), length(30f32)], @@ -33,60 +73,359 @@ fn grid_auto_rows__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 180f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node4, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node5, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node6, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node6, 150f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,36 +437,69 @@ fn grid_auto_rows__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![length(100f32)], grid_auto_rows: vec![length(10f32), length(20f32), length(30f32)], @@ -140,58 +512,357 @@ fn grid_auto_rows__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 180f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node4, 100f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node5, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node6, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node6, 150f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 150f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_single_item.rs b/tests/generated/grid/grid_auto_single_item.rs index a30100eed..d621411ae 100644 --- a/tests/generated/grid/grid_auto_single_item.rs +++ b/tests/generated/grid/grid_auto_single_item.rs @@ -4,24 +4,69 @@ fn grid_auto_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), length(40f32)], ..Default::default() @@ -33,66 +78,398 @@ fn grid_auto_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,41 +479,78 @@ fn grid_auto_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), length(40f32)], ..Default::default() @@ -148,64 +562,396 @@ fn grid_auto_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_single_item_fixed_width.rs b/tests/generated/grid/grid_auto_single_item_fixed_width.rs index 5ef7ed647..12d40f10a 100644 --- a/tests/generated/grid/grid_auto_single_item_fixed_width.rs +++ b/tests/generated/grid/grid_auto_single_item_fixed_width.rs @@ -4,24 +4,69 @@ fn grid_auto_single_item_fixed_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -34,66 +79,398 @@ fn grid_auto_single_item_fixed_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node1, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,41 +480,78 @@ fn grid_auto_single_item_fixed_width__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -150,64 +564,396 @@ fn grid_auto_single_item_fixed_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node1, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_single_item_fixed_width_with_definite_width.rs b/tests/generated/grid/grid_auto_single_item_fixed_width_with_definite_width.rs index ac9d0cfb9..8f65c0937 100644 --- a/tests/generated/grid/grid_auto_single_item_fixed_width_with_definite_width.rs +++ b/tests/generated/grid/grid_auto_single_item_fixed_width_with_definite_width.rs @@ -4,24 +4,69 @@ fn grid_auto_single_item_fixed_width_with_definite_width__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -34,66 +79,398 @@ fn grid_auto_single_item_fixed_width_with_definite_width__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,41 +480,78 @@ fn grid_auto_single_item_fixed_width_with_definite_width__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -150,64 +564,396 @@ fn grid_auto_single_item_fixed_width_with_definite_width__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 130f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 170f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 170f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_auto_takes_precedence_over_fr.rs b/tests/generated/grid/grid_auto_takes_precedence_over_fr.rs index 16b095d49..592c5c96f 100644 --- a/tests/generated/grid/grid_auto_takes_precedence_over_fr.rs +++ b/tests/generated/grid/grid_auto_takes_precedence_over_fr.rs @@ -4,12 +4,26 @@ fn grid_auto_takes_precedence_over_fr__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![auto(), fr(1f32)], size: taffy::geometry::Size { @@ -25,24 +39,125 @@ fn grid_auto_takes_precedence_over_fr__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -52,16 +167,28 @@ fn grid_auto_takes_precedence_over_fr__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![auto(), fr(1f32)], size: taffy::geometry::Size { @@ -77,22 +204,123 @@ fn grid_auto_takes_precedence_over_fr__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_available_space_greater_than_max_content.rs b/tests/generated/grid/grid_available_space_greater_than_max_content.rs index faa668505..8dba8cdf0 100644 --- a/tests/generated/grid/grid_available_space_greater_than_max_content.rs +++ b/tests/generated/grid/grid_available_space_greater_than_max_content.rs @@ -6,13 +6,25 @@ fn grid_available_space_greater_than_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_available_space_greater_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -39,24 +55,125 @@ fn grid_available_space_greater_than_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node1, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,27 @@ fn grid_available_space_greater_than_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -82,6 +213,10 @@ fn grid_available_space_greater_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -101,22 +236,123 @@ fn grid_available_space_greater_than_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node1, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_available_space_smaller_than_max_content.rs b/tests/generated/grid/grid_available_space_smaller_than_max_content.rs index 5649024bc..777a5980c 100644 --- a/tests/generated/grid/grid_available_space_smaller_than_max_content.rs +++ b/tests/generated/grid/grid_available_space_smaller_than_max_content.rs @@ -6,13 +6,25 @@ fn grid_available_space_smaller_than_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_available_space_smaller_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -39,24 +55,125 @@ fn grid_available_space_smaller_than_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,27 @@ fn grid_available_space_smaller_than_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -82,6 +213,10 @@ fn grid_available_space_smaller_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -101,22 +236,123 @@ fn grid_available_space_smaller_than_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_available_space_smaller_than_min_content.rs b/tests/generated/grid/grid_available_space_smaller_than_min_content.rs index d59cb1695..da5fee2d7 100644 --- a/tests/generated/grid/grid_available_space_smaller_than_min_content.rs +++ b/tests/generated/grid/grid_available_space_smaller_than_min_content.rs @@ -6,13 +6,25 @@ fn grid_available_space_smaller_than_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_available_space_smaller_than_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -39,24 +55,125 @@ fn grid_available_space_smaller_than_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,13 +184,27 @@ fn grid_available_space_smaller_than_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -82,6 +213,10 @@ fn grid_available_space_smaller_than_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], ..Default::default() }, @@ -101,22 +236,123 @@ fn grid_available_space_smaller_than_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_basic.rs b/tests/generated/grid/grid_basic.rs index 746bffdbf..6625516a8 100644 --- a/tests/generated/grid/grid_basic.rs +++ b/tests/generated/grid/grid_basic.rs @@ -4,19 +4,68 @@ fn grid_basic__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -32,66 +81,398 @@ fn grid_basic__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,37 +482,77 @@ fn grid_basic__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -147,64 +568,396 @@ fn grid_basic__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_basic_implicit_tracks.rs b/tests/generated/grid/grid_basic_implicit_tracks.rs index 1eed031de..d27ef88ce 100644 --- a/tests/generated/grid/grid_basic_implicit_tracks.rs +++ b/tests/generated/grid/grid_basic_implicit_tracks.rs @@ -4,9 +4,15 @@ fn grid_basic_implicit_tracks__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(35f32), height: taffy::style::Dimension::from_length(35f32), @@ -18,6 +24,10 @@ fn grid_basic_implicit_tracks__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![length(40f32)], ..Default::default() @@ -29,24 +39,125 @@ fn grid_basic_implicit_tracks__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node, 75f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node1, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node1, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,11 +167,16 @@ fn grid_basic_implicit_tracks__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(35f32), height: taffy::style::Dimension::from_length(35f32), @@ -73,6 +189,10 @@ fn grid_basic_implicit_tracks__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![length(40f32)], ..Default::default() @@ -84,22 +204,123 @@ fn grid_basic_implicit_tracks__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node, 75f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 75f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 75f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node1, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node1, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_basic_with_overflow.rs b/tests/generated/grid/grid_basic_with_overflow.rs index 77032fea5..4fa144598 100644 --- a/tests/generated/grid/grid_basic_with_overflow.rs +++ b/tests/generated/grid/grid_basic_with_overflow.rs @@ -4,20 +4,74 @@ fn grid_basic_with_overflow__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -33,72 +87,437 @@ fn grid_basic_with_overflow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node9, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node9, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -108,40 +527,84 @@ fn grid_basic_with_overflow__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node9 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -157,70 +620,435 @@ fn grid_basic_with_overflow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node9, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node9, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_basic_with_padding.rs b/tests/generated/grid/grid_basic_with_padding.rs index 88575cc1e..7a7721e73 100644 --- a/tests/generated/grid/grid_basic_with_padding.rs +++ b/tests/generated/grid/grid_basic_with_padding.rs @@ -4,19 +4,68 @@ fn grid_basic_with_padding__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -34,66 +83,398 @@ fn grid_basic_with_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -103,37 +484,77 @@ fn grid_basic_with_padding__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -151,64 +572,396 @@ fn grid_basic_with_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_display_none_fixed_size.rs b/tests/generated/grid/grid_display_none_fixed_size.rs index 73e77a4d7..17e2b8662 100644 --- a/tests/generated/grid/grid_display_none_fixed_size.rs +++ b/tests/generated/grid/grid_display_none_fixed_size.rs @@ -4,10 +4,17 @@ fn grid_display_none_fixed_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + flex_grow: 1f32, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -19,6 +26,10 @@ fn grid_display_none_fixed_size__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -32,24 +43,131 @@ fn grid_display_none_fixed_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +179,7 @@ fn grid_display_none_fixed_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, flex_grow: 1f32, ..Default::default() }) @@ -69,6 +188,7 @@ fn grid_display_none_fixed_size__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -81,6 +201,10 @@ fn grid_display_none_fixed_size__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -94,22 +218,129 @@ fn grid_display_none_fixed_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_definite_argument.rs b/tests/generated/grid/grid_fit_content_percent_definite_argument.rs index e14b306b0..f4866c1dc 100644 --- a/tests/generated/grid/grid_fit_content_percent_definite_argument.rs +++ b/tests/generated/grid/grid_fit_content_percent_definite_argument.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_definite_argument__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_definite_argument__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_fit_content_percent_definite_argument__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_fit_content_percent_definite_argument__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_fit_content_percent_definite_argument__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_fit_content_percent_definite_argument__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_definite_max_content.rs b/tests/generated/grid/grid_fit_content_percent_definite_max_content.rs index 19178629a..881d9a5dc 100644 --- a/tests/generated/grid/grid_fit_content_percent_definite_max_content.rs +++ b/tests/generated/grid/grid_fit_content_percent_definite_max_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_definite_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_definite_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_fit_content_percent_definite_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_fit_content_percent_definite_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_fit_content_percent_definite_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_fit_content_percent_definite_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_definite_min_content.rs b/tests/generated/grid/grid_fit_content_percent_definite_min_content.rs index 2f6dff85a..2e9b51576 100644 --- a/tests/generated/grid/grid_fit_content_percent_definite_min_content.rs +++ b/tests/generated/grid/grid_fit_content_percent_definite_min_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_definite_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_definite_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_fit_content_percent_definite_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_fit_content_percent_definite_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_fit_content_percent_definite_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_fit_content_percent_definite_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_indefinite_argument.rs b/tests/generated/grid/grid_fit_content_percent_indefinite_argument.rs index cd298e136..55d04114a 100644 --- a/tests/generated/grid/grid_fit_content_percent_indefinite_argument.rs +++ b/tests/generated/grid/grid_fit_content_percent_indefinite_argument.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_indefinite_argument__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_indefinite_argument__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_percent_indefinite_argument__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_percent_indefinite_argument__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_percent_indefinite_argument__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_percent_indefinite_argument__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_indefinite_max_content.rs b/tests/generated/grid/grid_fit_content_percent_indefinite_max_content.rs index bf03d5a7b..cc5f41ad3 100644 --- a/tests/generated/grid/grid_fit_content_percent_indefinite_max_content.rs +++ b/tests/generated/grid/grid_fit_content_percent_indefinite_max_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_indefinite_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_indefinite_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_percent_indefinite_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_percent_indefinite_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_percent_indefinite_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_percent_indefinite_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_indefinite_max_content_hidden.rs b/tests/generated/grid/grid_fit_content_percent_indefinite_max_content_hidden.rs index ddb406565..6d9908a68 100644 --- a/tests/generated/grid/grid_fit_content_percent_indefinite_max_content_hidden.rs +++ b/tests/generated/grid/grid_fit_content_percent_indefinite_max_content_hidden.rs @@ -21,6 +21,10 @@ fn grid_fit_content_percent_indefinite_max_content_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -32,36 +36,86 @@ fn grid_fit_content_percent_indefinite_max_content_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +143,10 @@ fn grid_fit_content_percent_indefinite_max_content_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -100,34 +158,84 @@ fn grid_fit_content_percent_indefinite_max_content_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_indefinite_min_content.rs b/tests/generated/grid/grid_fit_content_percent_indefinite_min_content.rs index e8c7dce00..9e9940ecd 100644 --- a/tests/generated/grid/grid_fit_content_percent_indefinite_min_content.rs +++ b/tests/generated/grid/grid_fit_content_percent_indefinite_min_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_percent_indefinite_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_percent_indefinite_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_percent_indefinite_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_percent_indefinite_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_percent_indefinite_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_percent_indefinite_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_percent_indefinite_min_content_hidden.rs b/tests/generated/grid/grid_fit_content_percent_indefinite_min_content_hidden.rs index 24de61f62..0d6c1ea93 100644 --- a/tests/generated/grid/grid_fit_content_percent_indefinite_min_content_hidden.rs +++ b/tests/generated/grid/grid_fit_content_percent_indefinite_min_content_hidden.rs @@ -21,6 +21,10 @@ fn grid_fit_content_percent_indefinite_min_content_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -32,36 +36,86 @@ fn grid_fit_content_percent_indefinite_min_content_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +143,10 @@ fn grid_fit_content_percent_indefinite_min_content_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(percent(0.5f32))], ..Default::default() @@ -100,34 +158,84 @@ fn grid_fit_content_percent_indefinite_min_content_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_points_argument.rs b/tests/generated/grid/grid_fit_content_points_argument.rs index ed804485e..846a83261 100644 --- a/tests/generated/grid/grid_fit_content_points_argument.rs +++ b/tests/generated/grid/grid_fit_content_points_argument.rs @@ -6,7 +6,13 @@ fn grid_fit_content_points_argument__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_points_argument__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_points_argument__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_points_argument__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_points_argument__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_points_argument__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_points_max_content.rs b/tests/generated/grid/grid_fit_content_points_max_content.rs index 71391871c..bba4646d8 100644 --- a/tests/generated/grid/grid_fit_content_points_max_content.rs +++ b/tests/generated/grid/grid_fit_content_points_max_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_points_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_points_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_points_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_points_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_points_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_points_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_points_min_content.rs b/tests/generated/grid/grid_fit_content_points_min_content.rs index 8411c8fe7..468c2c0bb 100644 --- a/tests/generated/grid/grid_fit_content_points_min_content.rs +++ b/tests/generated/grid/grid_fit_content_points_min_content.rs @@ -6,7 +6,13 @@ fn grid_fit_content_points_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_fit_content_points_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_fit_content_points_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_fit_content_points_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_fit_content_points_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_fit_content_points_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fit_content_points_min_content_hidden.rs b/tests/generated/grid/grid_fit_content_points_min_content_hidden.rs index bdfe88445..52b72b216 100644 --- a/tests/generated/grid/grid_fit_content_points_min_content_hidden.rs +++ b/tests/generated/grid/grid_fit_content_points_min_content_hidden.rs @@ -21,6 +21,10 @@ fn grid_fit_content_points_min_content_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -32,36 +36,86 @@ fn grid_fit_content_points_min_content_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -89,6 +143,10 @@ fn grid_fit_content_points_min_content_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fit_content(length(30f32))], ..Default::default() @@ -100,34 +158,84 @@ fn grid_fit_content_points_min_content_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 10f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 10f32, - layout.scroll_width() - ); + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_fixed_size_no_content_proportions.rs b/tests/generated/grid/grid_fr_fixed_size_no_content_proportions.rs index e37319ff4..ca8b6b5bc 100644 --- a/tests/generated/grid/grid_fr_fixed_size_no_content_proportions.rs +++ b/tests/generated/grid/grid_fr_fixed_size_no_content_proportions.rs @@ -4,13 +4,32 @@ fn grid_fr_fixed_size_no_content_proportions__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -23,30 +42,164 @@ fn grid_fr_fixed_size_no_content_proportions__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node1, 67f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,19 +209,35 @@ fn grid_fr_fixed_size_no_content_proportions__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, @@ -81,28 +250,162 @@ fn grid_fr_fixed_size_no_content_proportions__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 33f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node1, 67f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 33f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 33f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs b/tests/generated/grid/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs index 36df94bdc..950f1694d 100644 --- a/tests/generated/grid/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs +++ b/tests/generated/grid/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs @@ -4,12 +4,26 @@ fn grid_fr_fixed_size_no_content_proportions_sub_1_sum__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fr(0.3f32), fr(0.2f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -22,24 +36,125 @@ fn grid_fr_fixed_size_no_content_proportions_sub_1_sum__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,16 +164,28 @@ fn grid_fr_fixed_size_no_content_proportions_sub_1_sum__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![fr(0.3f32), fr(0.2f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -71,22 +198,123 @@ fn grid_fr_fixed_size_no_content_proportions_sub_1_sum__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_fixed_size_single_item.rs b/tests/generated/grid/grid_fr_fixed_size_single_item.rs index 95117686b..fc8a28ee5 100644 --- a/tests/generated/grid/grid_fr_fixed_size_single_item.rs +++ b/tests/generated/grid/grid_fr_fixed_size_single_item.rs @@ -4,24 +4,69 @@ fn grid_fr_fixed_size_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], size: taffy::geometry::Size { @@ -37,66 +82,398 @@ fn grid_fr_fixed_size_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node3, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node7, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node8, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node8, 80f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -106,41 +483,78 @@ fn grid_fr_fixed_size_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], size: taffy::geometry::Size { @@ -156,64 +570,396 @@ fn grid_fr_fixed_size_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node3, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node7, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node8, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node8, 80f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_no_sized_items_indefinite.rs b/tests/generated/grid/grid_fr_no_sized_items_indefinite.rs index 5ec030fe6..fd9e2573b 100644 --- a/tests/generated/grid/grid_fr_no_sized_items_indefinite.rs +++ b/tests/generated/grid/grid_fr_no_sized_items_indefinite.rs @@ -4,19 +4,68 @@ fn grid_fr_no_sized_items_indefinite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], ..Default::default() @@ -28,66 +77,398 @@ fn grid_fr_no_sized_items_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node7, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node8, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,37 +478,77 @@ fn grid_fr_no_sized_items_indefinite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], ..Default::default() @@ -139,64 +560,396 @@ fn grid_fr_no_sized_items_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node7, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node8, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_single_item_indefinite.rs b/tests/generated/grid/grid_fr_single_item_indefinite.rs index 10423fb81..2d55186af 100644 --- a/tests/generated/grid/grid_fr_single_item_indefinite.rs +++ b/tests/generated/grid/grid_fr_single_item_indefinite.rs @@ -4,24 +4,69 @@ fn grid_fr_single_item_indefinite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], size: taffy::geometry::Size { @@ -37,66 +82,398 @@ fn grid_fr_single_item_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node8, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -106,41 +483,78 @@ fn grid_fr_single_item_indefinite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], size: taffy::geometry::Size { @@ -156,64 +570,396 @@ fn grid_fr_single_item_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node8, 100f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_span_2_proportion.rs b/tests/generated/grid/grid_fr_span_2_proportion.rs index 476423fdd..2593da807 100644 --- a/tests/generated/grid/grid_fr_span_2_proportion.rs +++ b/tests/generated/grid/grid_fr_span_2_proportion.rs @@ -6,6 +6,7 @@ fn grid_fr_span_2_proportion__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -14,12 +15,26 @@ fn grid_fr_span_2_proportion__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32)], ..Default::default() @@ -31,30 +46,164 @@ fn grid_fr_span_2_proportion__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +215,7 @@ fn grid_fr_span_2_proportion__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -75,16 +225,28 @@ fn grid_fr_span_2_proportion__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32)], ..Default::default() @@ -96,28 +258,162 @@ fn grid_fr_span_2_proportion__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_span_2_proportion_sub_1_sum.rs b/tests/generated/grid/grid_fr_span_2_proportion_sub_1_sum.rs index 8d1e7b99c..35acf5dff 100644 --- a/tests/generated/grid/grid_fr_span_2_proportion_sub_1_sum.rs +++ b/tests/generated/grid/grid_fr_span_2_proportion_sub_1_sum.rs @@ -6,6 +6,7 @@ fn grid_fr_span_2_proportion_sub_1_sum__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -14,12 +15,26 @@ fn grid_fr_span_2_proportion_sub_1_sum__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0.2f32), fr(0.3f32)], ..Default::default() @@ -31,30 +46,164 @@ fn grid_fr_span_2_proportion_sub_1_sum__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node2, 24f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 24f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +215,7 @@ fn grid_fr_span_2_proportion_sub_1_sum__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -75,16 +225,28 @@ fn grid_fr_span_2_proportion_sub_1_sum__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0.2f32), fr(0.3f32)], ..Default::default() @@ -96,28 +258,162 @@ fn grid_fr_span_2_proportion_sub_1_sum__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node2, 24f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 24f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_span_2_proportion_with_non_spanned_track.rs b/tests/generated/grid/grid_fr_span_2_proportion_with_non_spanned_track.rs index 83894b0d2..93e4bca97 100644 --- a/tests/generated/grid/grid_fr_span_2_proportion_with_non_spanned_track.rs +++ b/tests/generated/grid/grid_fr_span_2_proportion_with_non_spanned_track.rs @@ -6,6 +6,7 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -14,14 +15,38 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], ..Default::default() @@ -33,42 +58,242 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node4, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +305,7 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -89,22 +315,42 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], ..Default::default() @@ -116,40 +362,240 @@ fn grid_fr_span_2_proportion_with_non_spanned_track__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node4, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_span_2_proportion_zero_sum.rs b/tests/generated/grid/grid_fr_span_2_proportion_zero_sum.rs index bdff8e561..8c69edd5e 100644 --- a/tests/generated/grid/grid_fr_span_2_proportion_zero_sum.rs +++ b/tests/generated/grid/grid_fr_span_2_proportion_zero_sum.rs @@ -6,6 +6,7 @@ fn grid_fr_span_2_proportion_zero_sum__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -14,12 +15,26 @@ fn grid_fr_span_2_proportion_zero_sum__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0f32), fr(0f32)], ..Default::default() @@ -31,30 +46,164 @@ fn grid_fr_span_2_proportion_zero_sum__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node2, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,6 +215,7 @@ fn grid_fr_span_2_proportion_zero_sum__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -75,16 +225,28 @@ fn grid_fr_span_2_proportion_zero_sum__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0f32), fr(0f32)], ..Default::default() @@ -96,28 +258,162 @@ fn grid_fr_span_2_proportion_zero_sum__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node2, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs b/tests/generated/grid/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs index 0cd7b7798..273d9011e 100644 --- a/tests/generated/grid/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs +++ b/tests/generated/grid/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs @@ -6,6 +6,7 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -14,14 +15,38 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0f32), fr(0f32), fr(0f32)], ..Default::default() @@ -33,42 +58,242 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,6 +305,7 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -89,22 +315,42 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![fr(0f32), fr(0f32), fr(0f32)], ..Default::default() @@ -116,40 +362,240 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_gap.rs b/tests/generated/grid/grid_gap.rs index 577738211..fd3ec4d55 100644 --- a/tests/generated/grid/grid_gap.rs +++ b/tests/generated/grid/grid_gap.rs @@ -4,19 +4,68 @@ fn grid_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(40f32), height: length(40f32) }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(40f32), height: length(40f32) }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 160f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_hidden.rs b/tests/generated/grid/grid_hidden.rs index a7a138733..3b94e2a2b 100644 --- a/tests/generated/grid/grid_hidden.rs +++ b/tests/generated/grid/grid_hidden.rs @@ -4,22 +4,71 @@ fn grid_hidden__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -35,66 +84,398 @@ fn grid_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node6, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -104,49 +485,80 @@ fn grid_hidden__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::None, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, ..Default::default() }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -162,64 +574,396 @@ fn grid_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node6, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_inflow_overflow_clip.rs b/tests/generated/grid/grid_inflow_overflow_clip.rs new file mode 100644 index 000000000..ce71433b6 --- /dev/null +++ b/tests/generated/grid/grid_inflow_overflow_clip.rs @@ -0,0 +1,281 @@ +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 68f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 68f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 46f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 46f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_inflow_overflow_hidden.rs b/tests/generated/grid/grid_inflow_overflow_hidden.rs new file mode 100644 index 000000000..a69adbb8b --- /dev/null +++ b/tests/generated/grid/grid_inflow_overflow_hidden.rs @@ -0,0 +1,289 @@ +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 72f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 72f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 64f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 64f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 50f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_inflow_overflow_scroll.rs b/tests/generated/grid/grid_inflow_overflow_scroll.rs new file mode 100644 index 000000000..3370cb6fa --- /dev/null +++ b/tests/generated/grid/grid_inflow_overflow_scroll.rs @@ -0,0 +1,289 @@ +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 87f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 87f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 79f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 79f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 65f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_inflow_overflow_visible.rs b/tests/generated/grid/grid_inflow_overflow_visible.rs new file mode 100644 index 000000000..d608d1953 --- /dev/null +++ b/tests/generated/grid/grid_inflow_overflow_visible.rs @@ -0,0 +1,287 @@ +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 68f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 68f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 58f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 58f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn grid_inflow_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(50f32), + height: taffy::style::Dimension::from_length(50f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 72f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 72f32, layout.size.width); + } + if layout.size.height != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 64f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 46f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 46f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + let layout = taffy.layout(node0).unwrap(); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/grid/grid_justify_content_center.rs b/tests/generated/grid/grid_justify_content_center.rs index d10abc097..52b07046e 100644 --- a/tests/generated/grid/grid_justify_content_center.rs +++ b/tests/generated/grid/grid_justify_content_center.rs @@ -4,19 +4,68 @@ fn grid_justify_content_center__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_center__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs index 684a33cf9..9b9c30e8e 100644 --- a/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_center_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_center_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_center_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node00, -10f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node02, 90f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node03, -10f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node04, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node05, 90f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node06, -10f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node07, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node08, 90f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_center_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Center), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_center_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_center_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node00, -10f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node02, 90f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node03, -10f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node04, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node05, 90f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node06, -10f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), -10f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node07, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node08, 90f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 90f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_center_with_padding_border.rs b/tests/generated/grid/grid_justify_content_center_with_padding_border.rs index 04e57a1f2..30a26bf44 100644 --- a/tests/generated/grid/grid_justify_content_center_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_center_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_center_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_center_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node0, 52f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node2, 132f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 132f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node3, 52f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node5, 132f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 132f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node6, 52f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node8, 132f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 132f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 132f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_center_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_center_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node0, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node1, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node2, 168f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node3, 88f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node4, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node5, 168f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node6, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node7, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node8, 168f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_end.rs b/tests/generated/grid/grid_justify_content_end.rs index 9eda790ff..a02e4c362 100644 --- a/tests/generated/grid/grid_justify_content_end.rs +++ b/tests/generated/grid/grid_justify_content_end.rs @@ -4,19 +4,68 @@ fn grid_justify_content_end__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_end__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs index 0ce55253f..e66ef370b 100644 --- a/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_end_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::End), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_end_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_end_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node00, -20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node03, -20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node04, 30f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node06, -20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node07, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_end_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::End), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_end_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_end_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node00, -20f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node03, -20f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node04, 30f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node06, -20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node07, 30f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_end_with_padding_border.rs b/tests/generated/grid/grid_justify_content_end_with_padding_border.rs index cb369f0b8..edf285539 100644 --- a/tests/generated/grid/grid_justify_content_end_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_end_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_end_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_end_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node0, 56f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 56f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node1, 96f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node2, 136f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node3, 56f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 56f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node4, 96f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node5, 136f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node6, 56f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 56f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 56f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node7, 96f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node8, 136f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_end_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_end_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node0, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node1, 168f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node2, 208f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node3, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node4, 168f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node5, 208f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 168f32, "x of node {:?}. Expected {}. Actual {}", node7, 168f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 168f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 168f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node8, 208f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_around.rs b/tests/generated/grid/grid_justify_content_space_around.rs index be1042c89..ca4540953 100644 --- a/tests/generated/grid/grid_justify_content_space_around.rs +++ b/tests/generated/grid/grid_justify_content_space_around.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_around__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_space_around__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node2, 147f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node3, 13f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node5, 147f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node6, 13f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node8, 147f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_space_around__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_space_around__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node2, 147f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node3, 13f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node5, 147f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node6, 13f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node8, 147f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 147f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 147f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs index a34d4d16a..480176ce6 100644 --- a/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_around_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_space_around_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_space_around_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_space_around_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceAround), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_space_around_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_space_around_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs b/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs index 8971a709e..89f7fd734 100644 --- a/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_around_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_space_around_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node0, 49f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 49f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node2, 135f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node3, 49f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 49f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node5, 135f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node6, 49f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 49f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node8, 135f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 135f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 135f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_space_around_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceAround), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_space_around_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 61f32, "x of node {:?}. Expected {}. Actual {}", node0, 61f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 61f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node1, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node2, 195f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 61f32, "x of node {:?}. Expected {}. Actual {}", node3, 61f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 61f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node4, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node5, 195f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 61f32, "x of node {:?}. Expected {}. Actual {}", node6, 61f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 61f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 61f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node7, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node8, 195f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_between.rs b/tests/generated/grid/grid_justify_content_space_between.rs index b71fe6fe3..353974a96 100644 --- a/tests/generated/grid/grid_justify_content_space_between.rs +++ b/tests/generated/grid/grid_justify_content_space_between.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_between__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_space_between__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_space_between__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_space_between__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 160f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs index 50dc26f9a..e23a8fd5a 100644 --- a/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_between_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_space_between_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_space_between_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_space_between_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceBetween), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_space_between_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_space_between_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs b/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs index 8a55a815d..4e5e89f66 100644 --- a/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_between_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_space_between_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node2, 136f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node5, 136f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node8, 136f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 136f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 136f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_space_between_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceBetween), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_space_between_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node1, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node2, 208f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node4, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node5, 208f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node7, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 208f32, "x of node {:?}. Expected {}. Actual {}", node8, 208f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 208f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 208f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_evenly.rs b/tests/generated/grid/grid_justify_content_space_evenly.rs index 715b30d0b..b0aae3a92 100644 --- a/tests/generated/grid/grid_justify_content_space_evenly.rs +++ b/tests/generated/grid/grid_justify_content_space_evenly.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_evenly__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_space_evenly__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node6, 20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_space_evenly__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_space_evenly__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node6, 20f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 140f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs index 70289b6d1..289f27159 100644 --- a/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_evenly_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_space_evenly_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_space_evenly_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_space_evenly_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_space_evenly_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_space_evenly_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs b/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs index 2d5024b13..3f15dd227 100644 --- a/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_space_evenly_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_space_evenly_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node2, 134f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 134f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 134f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node5, 134f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 134f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 134f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node6, 50f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 92f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node8, 134f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 134f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 134f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_space_evenly_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_space_evenly_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node0, 68f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 68f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node1, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 188f32, "x of node {:?}. Expected {}. Actual {}", node2, 188f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 188f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node3, 68f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 68f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node4, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 188f32, "x of node {:?}. Expected {}. Actual {}", node5, 188f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 188f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node6, 68f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 68f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 68f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node7, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 188f32, "x of node {:?}. Expected {}. Actual {}", node8, 188f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 188f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 188f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_start.rs b/tests/generated/grid/grid_justify_content_start.rs index 5327c11c7..608a2edff 100644 --- a/tests/generated/grid/grid_justify_content_start.rs +++ b/tests/generated/grid/grid_justify_content_start.rs @@ -4,19 +4,68 @@ fn grid_justify_content_start__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -33,66 +82,398 @@ fn grid_justify_content_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,37 +483,77 @@ fn grid_justify_content_start__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -149,64 +570,396 @@ fn grid_justify_content_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs b/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs index 87bbd6af9..19f508fb4 100644 --- a/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs +++ b/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs @@ -4,19 +4,68 @@ fn grid_justify_content_start_negative_space_gap__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node04 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node05 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node06 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node07 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node08 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Start), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -35,6 +84,10 @@ fn grid_justify_content_start_negative_space_gap__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -54,72 +107,497 @@ fn grid_justify_content_start_negative_space_gap__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); - assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 240f32, layout.size.width); + } + if layout.size.height != 240f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 240f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,37 +607,77 @@ fn grid_justify_content_start_negative_space_gap__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node04 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node05 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node06 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node07 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node08 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_content: Some(taffy::style::AlignContent::Center), justify_content: Some(taffy::style::JustifyContent::Start), gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) }, @@ -179,6 +697,10 @@ fn grid_justify_content_start_negative_space_gap__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(240f32), height: taffy::style::Dimension::from_length(240f32), @@ -198,70 +720,495 @@ fn grid_justify_content_start_negative_space_gap__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width); - assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 360f32, layout.size.width); + } + if layout.size.height != 360f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 360f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 120f32, + layout.size.height + ); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node02, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node02, 100f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node02, 20f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node03, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node03, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node03, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node04).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node04, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node04, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node04, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node04, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node05).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node05, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node05, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node05, 100f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node05, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node05, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node06).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node06, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node06, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node06, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node06, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node06, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node06, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node07).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node07, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node07, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node07, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node07, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node07, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node08).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node08, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node08, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node08, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node08, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node08, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node08, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_content_start_with_padding_border.rs b/tests/generated/grid/grid_justify_content_start_with_padding_border.rs index 8f531a0e5..de6fae25f 100644 --- a/tests/generated/grid/grid_justify_content_start_with_padding_border.rs +++ b/tests/generated/grid/grid_justify_content_start_with_padding_border.rs @@ -4,19 +4,68 @@ fn grid_justify_content_start_with_padding_border__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -45,66 +94,398 @@ fn grid_justify_content_start_with_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -114,37 +495,77 @@ fn grid_justify_content_start_with_padding_border__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -173,64 +594,396 @@ fn grid_justify_content_start_with_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node, 272f32, size.width); - assert_eq!(size.height, 248f32, "height of node {:?}. Expected {}. Actual {}", node, 248f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 272f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 272f32, layout.size.width); + } + if layout.size.height != 248f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 248f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); - assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 12f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 88f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 88f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); - assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node8, 92f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 92f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_items_sized_center.rs b/tests/generated/grid/grid_justify_items_sized_center.rs index 61a10d4d6..704e15e74 100644 --- a/tests/generated/grid/grid_justify_items_sized_center.rs +++ b/tests/generated/grid/grid_justify_items_sized_center.rs @@ -6,6 +6,7 @@ fn grid_justify_items_sized_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_justify_items_sized_center__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_justify_items_sized_center__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_justify_items_sized_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_justify_items_sized_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_justify_items_sized_center__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_justify_items_sized_center__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Center), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_justify_items_sized_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_items_sized_end.rs b/tests/generated/grid/grid_justify_items_sized_end.rs index 6ab39f704..16a994ccb 100644 --- a/tests/generated/grid/grid_justify_items_sized_end.rs +++ b/tests/generated/grid/grid_justify_items_sized_end.rs @@ -6,6 +6,7 @@ fn grid_justify_items_sized_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_justify_items_sized_end__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_justify_items_sized_end__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_justify_items_sized_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_justify_items_sized_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_justify_items_sized_end__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_justify_items_sized_end__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::End), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_justify_items_sized_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_items_sized_start.rs b/tests/generated/grid/grid_justify_items_sized_start.rs index 469beabcc..480bde3fe 100644 --- a/tests/generated/grid/grid_justify_items_sized_start.rs +++ b/tests/generated/grid/grid_justify_items_sized_start.rs @@ -6,6 +6,7 @@ fn grid_justify_items_sized_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_justify_items_sized_start__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_justify_items_sized_start__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_justify_items_sized_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_justify_items_sized_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_justify_items_sized_start__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_justify_items_sized_start__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Start), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_justify_items_sized_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_items_sized_stretch.rs b/tests/generated/grid/grid_justify_items_sized_stretch.rs index d9d4d0e8a..60615c95c 100644 --- a/tests/generated/grid/grid_justify_items_sized_stretch.rs +++ b/tests/generated/grid/grid_justify_items_sized_stretch.rs @@ -6,6 +6,7 @@ fn grid_justify_items_sized_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_justify_items_sized_stretch__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -30,6 +32,10 @@ fn grid_justify_items_sized_stretch__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Stretch), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -46,24 +52,125 @@ fn grid_justify_items_sized_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,6 +182,7 @@ fn grid_justify_items_sized_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -87,6 +195,7 @@ fn grid_justify_items_sized_stretch__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -101,6 +210,10 @@ fn grid_justify_items_sized_stretch__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Stretch), grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], @@ -117,22 +230,123 @@ fn grid_justify_items_sized_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_justify_self_sized_all.rs b/tests/generated/grid/grid_justify_self_sized_all.rs index 1101aac93..e1afc8237 100644 --- a/tests/generated/grid/grid_justify_self_sized_all.rs +++ b/tests/generated/grid/grid_justify_self_sized_all.rs @@ -6,6 +6,7 @@ fn grid_justify_self_sized_all__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -16,6 +17,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -26,6 +28,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -36,6 +39,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -46,6 +50,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -56,6 +61,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -66,6 +72,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -76,6 +83,7 @@ fn grid_justify_self_sized_all__border_box() { .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -88,6 +96,10 @@ fn grid_justify_self_sized_all__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -103,60 +115,359 @@ fn grid_justify_self_sized_all__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node3, -20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -168,6 +479,7 @@ fn grid_justify_self_sized_all__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -179,6 +491,7 @@ fn grid_justify_self_sized_all__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -190,6 +503,7 @@ fn grid_justify_self_sized_all__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -201,6 +515,7 @@ fn grid_justify_self_sized_all__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -212,6 +527,7 @@ fn grid_justify_self_sized_all__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -223,6 +539,7 @@ fn grid_justify_self_sized_all__content_box() { let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -234,6 +551,7 @@ fn grid_justify_self_sized_all__content_box() { let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), @@ -245,6 +563,7 @@ fn grid_justify_self_sized_all__content_box() { let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), @@ -258,6 +577,10 @@ fn grid_justify_self_sized_all__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -273,58 +596,357 @@ fn grid_justify_self_sized_all__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); - assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node3, -20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != -20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), -20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_auto_margins.rs b/tests/generated/grid/grid_margins_auto_margins.rs index 2776bf79b..1bd1a1aac 100644 --- a/tests/generated/grid/grid_margins_auto_margins.rs +++ b/tests/generated/grid/grid_margins_auto_margins.rs @@ -4,10 +4,21 @@ fn grid_margins_auto_margins__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, margin: taffy::geometry::Rect { @@ -19,9 +30,15 @@ fn grid_margins_auto_margins__border_box() { ..Default::default() }) .unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, margin: taffy::geometry::Rect { @@ -33,9 +50,15 @@ fn grid_margins_auto_margins__border_box() { ..Default::default() }) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -51,12 +74,26 @@ fn grid_margins_auto_margins__border_box() { ..Default::default() }) .unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -74,66 +111,398 @@ fn grid_margins_auto_margins__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node2, 130f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node6, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node6, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -143,14 +512,23 @@ fn grid_margins_auto_margins__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, margin: taffy::geometry::Rect { @@ -163,11 +541,16 @@ fn grid_margins_auto_margins__content_box() { }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) }, margin: taffy::geometry::Rect { @@ -180,11 +563,16 @@ fn grid_margins_auto_margins__content_box() { }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -201,16 +589,28 @@ fn grid_margins_auto_margins__content_box() { }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -228,64 +628,396 @@ fn grid_margins_auto_margins__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node2, 130f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 130f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 130f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 60f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node6, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node6, 100f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 100f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs b/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs index 59c434b1a..94db43591 100644 --- a/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs +++ b/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs @@ -4,15 +4,49 @@ fn grid_margins_auto_margins_override_stretch__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node6 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), margin: taffy::geometry::Rect { @@ -26,12 +60,26 @@ fn grid_margins_auto_margins_override_stretch__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -49,66 +97,398 @@ fn grid_margins_auto_margins_override_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 105f32, "y of node {:?}. Expected {}. Actual {}", node6, 105f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 105f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 105f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,27 +498,55 @@ fn grid_margins_auto_margins_override_stretch__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), margin: taffy::geometry::Rect { @@ -153,16 +561,28 @@ fn grid_margins_auto_margins_override_stretch__content_box() { ) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -180,64 +600,396 @@ fn grid_margins_auto_margins_override_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 105f32, "y of node {:?}. Expected {}. Actual {}", node6, 105f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 105f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 105f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); - assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 90f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_fixed_center.rs b/tests/generated/grid/grid_margins_fixed_center.rs index fe60c1b9b..5215296d6 100644 --- a/tests/generated/grid/grid_margins_fixed_center.rs +++ b/tests/generated/grid/grid_margins_fixed_center.rs @@ -6,6 +6,7 @@ fn grid_margins_fixed_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_fixed_center__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -47,48 +77,281 @@ fn grid_margins_fixed_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node0, 52f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +363,7 @@ fn grid_margins_fixed_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { @@ -116,25 +380,49 @@ fn grid_margins_fixed_center__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -152,46 +440,279 @@ fn grid_margins_fixed_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node0, 52f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 52f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_fixed_end.rs b/tests/generated/grid/grid_margins_fixed_end.rs index 56d79e053..d80dd8f23 100644 --- a/tests/generated/grid/grid_margins_fixed_end.rs +++ b/tests/generated/grid/grid_margins_fixed_end.rs @@ -6,6 +6,7 @@ fn grid_margins_fixed_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_fixed_end__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -47,48 +77,281 @@ fn grid_margins_fixed_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 58f32, "x of node {:?}. Expected {}. Actual {}", node0, 58f32, location.x); - assert_eq!(location.y, 27f32, "y of node {:?}. Expected {}. Actual {}", node0, 27f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 58f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 58f32, layout.location.x); + } + if layout.location.y != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 27f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +363,7 @@ fn grid_margins_fixed_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -116,25 +380,49 @@ fn grid_margins_fixed_end__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -152,46 +440,279 @@ fn grid_margins_fixed_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 58f32, "x of node {:?}. Expected {}. Actual {}", node0, 58f32, location.x); - assert_eq!(location.y, 27f32, "y of node {:?}. Expected {}. Actual {}", node0, 27f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 58f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 58f32, layout.location.x); + } + if layout.location.y != 27f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 27f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_fixed_start.rs b/tests/generated/grid/grid_margins_fixed_start.rs index 846faa45a..d8d72fd18 100644 --- a/tests/generated/grid/grid_margins_fixed_start.rs +++ b/tests/generated/grid/grid_margins_fixed_start.rs @@ -6,6 +6,7 @@ fn grid_margins_fixed_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_fixed_start__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -47,48 +77,281 @@ fn grid_margins_fixed_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +363,7 @@ fn grid_margins_fixed_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -116,25 +380,49 @@ fn grid_margins_fixed_start__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -152,46 +440,279 @@ fn grid_margins_fixed_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_fixed_stretch.rs b/tests/generated/grid/grid_margins_fixed_stretch.rs index 28cefc25e..16f3f29f3 100644 --- a/tests/generated/grid/grid_margins_fixed_stretch.rs +++ b/tests/generated/grid/grid_margins_fixed_stretch.rs @@ -6,6 +6,7 @@ fn grid_margins_fixed_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_fixed_stretch__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -47,48 +77,281 @@ fn grid_margins_fixed_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -100,6 +363,7 @@ fn grid_margins_fixed_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { @@ -116,25 +380,49 @@ fn grid_margins_fixed_stretch__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], padding: taffy::geometry::Rect { @@ -152,46 +440,279 @@ fn grid_margins_fixed_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); - assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 180f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 180f32, layout.size.width); + } + if layout.size.height != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 160f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); - assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 44f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 44f32, layout.location.x); + } + if layout.location.y != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 120f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_percent_center.rs b/tests/generated/grid/grid_margins_percent_center.rs index 3af648582..b5060e2fa 100644 --- a/tests/generated/grid/grid_margins_percent_center.rs +++ b/tests/generated/grid/grid_margins_percent_center.rs @@ -6,6 +6,7 @@ fn grid_margins_percent_center__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_percent_center__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -41,48 +71,281 @@ fn grid_margins_percent_center__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 9f32, "y of node {:?}. Expected {}. Actual {}", node0, 9f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 9f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -94,6 +357,7 @@ fn grid_margins_percent_center__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Center), justify_self: Some(taffy::style::JustifySelf::Center), size: taffy::geometry::Size { @@ -110,25 +374,49 @@ fn grid_margins_percent_center__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -140,46 +428,279 @@ fn grid_margins_percent_center__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); - assert_eq!(location.y, 9f32, "y of node {:?}. Expected {}. Actual {}", node0, 9f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 1f32, layout.location.x); + } + if layout.location.y != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 9f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_percent_end.rs b/tests/generated/grid/grid_margins_percent_end.rs index af83c42b8..d401acf08 100644 --- a/tests/generated/grid/grid_margins_percent_end.rs +++ b/tests/generated/grid/grid_margins_percent_end.rs @@ -6,6 +6,7 @@ fn grid_margins_percent_end__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_percent_end__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -41,48 +71,281 @@ fn grid_margins_percent_end__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, -2f32, "x of node {:?}. Expected {}. Actual {}", node0, -2f32, location.x); - assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node0, 17f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != -2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -2f32, layout.location.x); + } + if layout.location.y != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 17f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -94,6 +357,7 @@ fn grid_margins_percent_end__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::End), justify_self: Some(taffy::style::JustifySelf::End), size: taffy::geometry::Size { @@ -110,25 +374,49 @@ fn grid_margins_percent_end__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -140,46 +428,279 @@ fn grid_margins_percent_end__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, -2f32, "x of node {:?}. Expected {}. Actual {}", node0, -2f32, location.x); - assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node0, 17f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != -2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), -2f32, layout.location.x); + } + if layout.location.y != 17f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 17f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_percent_start.rs b/tests/generated/grid/grid_margins_percent_start.rs index 2516fd601..771e5855f 100644 --- a/tests/generated/grid/grid_margins_percent_start.rs +++ b/tests/generated/grid/grid_margins_percent_start.rs @@ -6,6 +6,7 @@ fn grid_margins_percent_start__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_percent_start__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -41,48 +71,281 @@ fn grid_margins_percent_start__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -94,6 +357,7 @@ fn grid_margins_percent_start__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { @@ -110,25 +374,49 @@ fn grid_margins_percent_start__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -140,46 +428,279 @@ fn grid_margins_percent_start__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_margins_percent_stretch.rs b/tests/generated/grid/grid_margins_percent_stretch.rs index 1bf0f9ca8..aa143ad6c 100644 --- a/tests/generated/grid/grid_margins_percent_stretch.rs +++ b/tests/generated/grid/grid_margins_percent_stretch.rs @@ -6,6 +6,7 @@ fn grid_margins_percent_stretch__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { @@ -21,15 +22,44 @@ fn grid_margins_percent_stretch__border_box() { ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -41,48 +71,281 @@ fn grid_margins_percent_stretch__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -94,6 +357,7 @@ fn grid_margins_percent_stretch__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, align_self: Some(taffy::style::AlignSelf::Stretch), justify_self: Some(taffy::style::JustifySelf::Stretch), size: taffy::geometry::Size { @@ -110,25 +374,49 @@ fn grid_margins_percent_stretch__content_box() { }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() @@ -140,46 +428,279 @@ fn grid_margins_percent_stretch__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 4f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_maximum_single_item.rs b/tests/generated/grid/grid_max_content_maximum_single_item.rs index e74e10d7a..0b8a96057 100644 --- a/tests/generated/grid/grid_max_content_maximum_single_item.rs +++ b/tests/generated/grid/grid_max_content_maximum_single_item.rs @@ -4,24 +4,74 @@ fn grid_max_content_maximum_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(0f32), max_content()), length(40f32)], ..Default::default() @@ -33,66 +83,398 @@ fn grid_max_content_maximum_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,40 +484,83 @@ fn grid_max_content_maximum_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(0f32), max_content()), length(40f32)], ..Default::default() @@ -147,64 +572,396 @@ fn grid_max_content_maximum_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item.rs b/tests/generated/grid/grid_max_content_single_item.rs index e79eb874c..ea92ff7e7 100644 --- a/tests/generated/grid/grid_max_content_single_item.rs +++ b/tests/generated/grid/grid_max_content_single_item.rs @@ -4,24 +4,74 @@ fn grid_max_content_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -33,66 +83,398 @@ fn grid_max_content_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,40 +484,83 @@ fn grid_max_content_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -147,64 +572,396 @@ fn grid_max_content_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_margin_auto.rs b/tests/generated/grid/grid_max_content_single_item_margin_auto.rs index e9ef47ec5..7204b2cd8 100644 --- a/tests/generated/grid/grid_max_content_single_item_margin_auto.rs +++ b/tests/generated/grid/grid_max_content_single_item_margin_auto.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_margin_auto__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: taffy::style::LengthPercentageAuto::AUTO, @@ -19,17 +28,56 @@ fn grid_max_content_single_item_margin_auto__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -41,66 +89,398 @@ fn grid_max_content_single_item_margin_auto__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -110,12 +490,20 @@ fn grid_max_content_single_item_margin_auto__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, right: taffy::style::LengthPercentageAuto::AUTO, @@ -128,31 +516,63 @@ fn grid_max_content_single_item_margin_auto__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -164,64 +584,396 @@ fn grid_max_content_single_item_margin_auto__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 15f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs b/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs index 3ec8c33e6..7076f1251 100644 --- a/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs +++ b/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_margin_fixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: length(20f32), right: length(10f32), @@ -19,17 +28,56 @@ fn grid_max_content_single_item_margin_fixed__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -41,66 +89,398 @@ fn grid_max_content_single_item_margin_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node2, 110f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node4, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node5, 110f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node7, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node8, 110f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -110,12 +490,20 @@ fn grid_max_content_single_item_margin_fixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: length(20f32), right: length(10f32), @@ -128,31 +516,63 @@ fn grid_max_content_single_item_margin_fixed__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -164,64 +584,396 @@ fn grid_max_content_single_item_margin_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 150f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 150f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node2, 110f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node4, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node5, 110f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node7, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node8, 110f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 110f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_margin_percent.rs b/tests/generated/grid/grid_max_content_single_item_margin_percent.rs index f44276391..9863e95ec 100644 --- a/tests/generated/grid/grid_max_content_single_item_margin_percent.rs +++ b/tests/generated/grid/grid_max_content_single_item_margin_percent.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_margin_percent__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: percent(0.2f32), right: percent(0.1f32), @@ -19,17 +28,56 @@ fn grid_max_content_single_item_margin_percent__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -41,66 +89,398 @@ fn grid_max_content_single_item_margin_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node1, 28f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -110,12 +490,20 @@ fn grid_max_content_single_item_margin_percent__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, margin: taffy::geometry::Rect { left: percent(0.2f32), right: percent(0.1f32), @@ -128,31 +516,63 @@ fn grid_max_content_single_item_margin_percent__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), length(40f32)], ..Default::default() @@ -164,64 +584,396 @@ fn grid_max_content_single_item_margin_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node1, 28f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); - assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 2f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_span_2.rs b/tests/generated/grid/grid_max_content_single_item_span_2.rs index c116506da..849b3d5e4 100644 --- a/tests/generated/grid/grid_max_content_single_item_span_2.rs +++ b/tests/generated/grid/grid_max_content_single_item_span_2.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_span_2__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -17,17 +26,56 @@ fn grid_max_content_single_item_span_2__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], ..Default::default() @@ -39,66 +87,398 @@ fn grid_max_content_single_item_span_2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node7, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -108,12 +488,20 @@ fn grid_max_content_single_item_span_2__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -124,31 +512,63 @@ fn grid_max_content_single_item_span_2__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], ..Default::default() @@ -160,64 +580,396 @@ fn grid_max_content_single_item_span_2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node7, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs b/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs index 4d27357b3..ca7904508 100644 --- a/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs +++ b/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_span_2_gap_fixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -17,17 +26,56 @@ fn grid_max_content_single_item_span_2_gap_fixed__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(20f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -40,66 +88,398 @@ fn grid_max_content_single_item_span_2_gap_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -109,12 +489,20 @@ fn grid_max_content_single_item_span_2_gap_fixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -125,31 +513,63 @@ fn grid_max_content_single_item_span_2_gap_fixed__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: length(20f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -162,64 +582,396 @@ fn grid_max_content_single_item_span_2_gap_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs b/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs index dc495d3d0..d6343ae7d 100644 --- a/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs +++ b/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -17,17 +26,56 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -41,66 +89,398 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -110,12 +490,20 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -126,31 +514,63 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -164,64 +584,396 @@ fn grid_max_content_single_item_span_2_gap_percent_definite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs b/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs index 7f59bc87a..2f7f9616c 100644 --- a/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs +++ b/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs @@ -4,10 +4,19 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -17,17 +26,56 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -40,66 +88,398 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -109,12 +489,20 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -125,31 +513,63 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__content_box() { ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, gap: taffy::geometry::Size { width: percent(0.2f32), height: zero() }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), max_content(), max_content()], @@ -162,64 +582,396 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); - assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node8, 120f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 120f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_width_greater_than_max_content.rs b/tests/generated/grid/grid_max_width_greater_than_max_content.rs index d77084e0c..99e3a2858 100644 --- a/tests/generated/grid/grid_max_width_greater_than_max_content.rs +++ b/tests/generated/grid/grid_max_width_greater_than_max_content.rs @@ -6,13 +6,25 @@ fn grid_max_width_greater_than_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_max_width_greater_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, ..Default::default() @@ -31,6 +47,10 @@ fn grid_max_width_greater_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -41,30 +61,176 @@ fn grid_max_width_greater_than_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node01, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,13 +241,27 @@ fn grid_max_width_greater_than_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -90,6 +270,10 @@ fn grid_max_width_greater_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(400f32), height: auto() }, ..Default::default() @@ -102,6 +286,10 @@ fn grid_max_width_greater_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -112,28 +300,174 @@ fn grid_max_width_greater_than_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node01, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs b/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs index 0b749b8da..c2b3228a0 100644 --- a/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs +++ b/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs @@ -6,13 +6,25 @@ fn grid_max_width_less_than_max_content_with_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_max_width_less_than_max_content_with_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -31,6 +47,10 @@ fn grid_max_width_less_than_max_content_with_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -41,30 +61,176 @@ fn grid_max_width_less_than_max_content_with_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,13 +241,27 @@ fn grid_max_width_less_than_max_content_with_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -90,6 +270,10 @@ fn grid_max_width_less_than_max_content_with_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -102,6 +286,10 @@ fn grid_max_width_less_than_max_content_with_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![min_content()], ..Default::default() }, @@ -112,28 +300,174 @@ fn grid_max_width_less_than_max_content_with_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_width_smaller_than_max_content.rs b/tests/generated/grid/grid_max_width_smaller_than_max_content.rs index e30c449c2..8f0f374e1 100644 --- a/tests/generated/grid/grid_max_width_smaller_than_max_content.rs +++ b/tests/generated/grid/grid_max_width_smaller_than_max_content.rs @@ -6,13 +6,25 @@ fn grid_max_width_smaller_than_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_max_width_smaller_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -31,6 +47,10 @@ fn grid_max_width_smaller_than_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -41,30 +61,176 @@ fn grid_max_width_smaller_than_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,13 +241,27 @@ fn grid_max_width_smaller_than_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -90,6 +270,10 @@ fn grid_max_width_smaller_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() }, ..Default::default() @@ -102,6 +286,10 @@ fn grid_max_width_smaller_than_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -112,28 +300,174 @@ fn grid_max_width_smaller_than_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_max_width_smaller_than_min_content.rs b/tests/generated/grid/grid_max_width_smaller_than_min_content.rs index e024c4548..ae631a53e 100644 --- a/tests/generated/grid/grid_max_width_smaller_than_min_content.rs +++ b/tests/generated/grid/grid_max_width_smaller_than_min_content.rs @@ -6,13 +6,25 @@ fn grid_max_width_smaller_than_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -20,6 +32,10 @@ fn grid_max_width_smaller_than_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -31,6 +47,10 @@ fn grid_max_width_smaller_than_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -41,30 +61,176 @@ fn grid_max_width_smaller_than_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -75,13 +241,27 @@ fn grid_max_width_smaller_than_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -90,6 +270,10 @@ fn grid_max_width_smaller_than_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![auto(), auto()], max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, ..Default::default() @@ -102,6 +286,10 @@ fn grid_max_width_smaller_than_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![max_content()], ..Default::default() }, @@ -112,28 +300,174 @@ fn grid_max_width_smaller_than_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node01, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_column.rs b/tests/generated/grid/grid_min_content_flex_column.rs index c1d81e5b4..6f82705c8 100644 --- a/tests/generated/grid/grid_min_content_flex_column.rs +++ b/tests/generated/grid/grid_min_content_flex_column.rs @@ -6,19 +6,37 @@ fn grid_min_content_flex_column__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -27,6 +45,10 @@ fn grid_min_content_flex_column__border_box() { taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01, node02], @@ -36,6 +58,10 @@ fn grid_min_content_flex_column__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -47,36 +73,221 @@ fn grid_min_content_flex_column__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,19 +298,40 @@ fn grid_min_content_flex_column__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -109,6 +341,10 @@ fn grid_min_content_flex_column__content_box() { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01, node02], @@ -119,6 +355,10 @@ fn grid_min_content_flex_column__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -130,34 +370,219 @@ fn grid_min_content_flex_column__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 20f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_row.rs b/tests/generated/grid/grid_min_content_flex_row.rs index de94a737c..8fe6d2cce 100644 --- a/tests/generated/grid/grid_min_content_flex_row.rs +++ b/tests/generated/grid/grid_min_content_flex_row.rs @@ -6,25 +6,50 @@ fn grid_min_content_flex_row__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Flex, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00, node01, node02], ) .unwrap(); @@ -32,6 +57,10 @@ fn grid_min_content_flex_row__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -43,36 +72,221 @@ fn grid_min_content_flex_row__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -83,19 +297,40 @@ fn grid_min_content_flex_row__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -104,6 +339,10 @@ fn grid_min_content_flex_row__content_box() { taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00, node01, node02], @@ -114,6 +353,10 @@ fn grid_min_content_flex_row__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -125,34 +368,219 @@ fn grid_min_content_flex_row__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_single_item.rs b/tests/generated/grid/grid_min_content_flex_single_item.rs index 9931da498..86fdc3a01 100644 --- a/tests/generated/grid/grid_min_content_flex_single_item.rs +++ b/tests/generated/grid/grid_min_content_flex_single_item.rs @@ -4,18 +4,38 @@ fn grid_min_content_flex_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -25,13 +45,32 @@ fn grid_min_content_flex_single_item__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -43,60 +82,359 @@ fn grid_min_content_flex_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -106,25 +444,42 @@ fn grid_min_content_flex_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -135,19 +490,35 @@ fn grid_min_content_flex_single_item__content_box() { ) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -159,58 +530,357 @@ fn grid_min_content_flex_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs b/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs index 91466cecf..ed06b229a 100644 --- a/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs +++ b/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs @@ -4,9 +4,15 @@ fn grid_min_content_flex_single_item_margin_auto__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, @@ -17,11 +23,25 @@ fn grid_min_content_flex_single_item_margin_auto__border_box() { ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -37,13 +57,32 @@ fn grid_min_content_flex_single_item_margin_auto__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -55,60 +94,359 @@ fn grid_min_content_flex_single_item_margin_auto__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node4, 55f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,11 +456,16 @@ fn grid_min_content_flex_single_item_margin_auto__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::AUTO, @@ -134,15 +477,27 @@ fn grid_min_content_flex_single_item_margin_auto__content_box() { }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -159,19 +514,35 @@ fn grid_min_content_flex_single_item_margin_auto__content_box() { ) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -183,58 +554,357 @@ fn grid_min_content_flex_single_item_margin_auto__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 20f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node4, 55f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 55f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 55f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs b/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs index 94b8f70df..516987956 100644 --- a/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs +++ b/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs @@ -4,9 +4,15 @@ fn grid_min_content_flex_single_item_margin_fixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: length(20f32), @@ -17,11 +23,25 @@ fn grid_min_content_flex_single_item_margin_fixed__border_box() { ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -37,13 +57,32 @@ fn grid_min_content_flex_single_item_margin_fixed__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -55,60 +94,359 @@ fn grid_min_content_flex_single_item_margin_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,11 +456,16 @@ fn grid_min_content_flex_single_item_margin_fixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: length(20f32), @@ -134,15 +477,27 @@ fn grid_min_content_flex_single_item_margin_fixed__content_box() { }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -159,19 +514,35 @@ fn grid_min_content_flex_single_item_margin_fixed__content_box() { ) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -183,58 +554,357 @@ fn grid_min_content_flex_single_item_margin_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); - assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 45f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs b/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs index 7ca175aef..e0b7bdd74 100644 --- a/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs +++ b/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs @@ -4,9 +4,15 @@ fn grid_min_content_flex_single_item_margin_percent__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -17,11 +23,25 @@ fn grid_min_content_flex_single_item_margin_percent__border_box() { ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -37,13 +57,32 @@ fn grid_min_content_flex_single_item_margin_percent__border_box() { crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -55,60 +94,359 @@ fn grid_min_content_flex_single_item_margin_percent__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 38f32, "height of node {:?}. Expected {}. Actual {}", node1, 38f32, size.height); - assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node1, 42f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node1, 1f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 38f32, layout.size.height); + } + if layout.location.x != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 42f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node4, 28f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node4, 32f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); - assert_eq!(location.y, 42f32, "y of node {:?}. Expected {}. Actual {}", node4, 42f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 42f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -118,11 +456,16 @@ fn grid_min_content_flex_single_item_margin_percent__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.2f32), @@ -134,15 +477,27 @@ fn grid_min_content_flex_single_item_margin_percent__content_box() { }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Span(2u16), end: taffy::style::GridPlacement::Auto, @@ -159,19 +514,35 @@ fn grid_min_content_flex_single_item_margin_percent__content_box() { ) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], ..Default::default() @@ -183,58 +554,357 @@ fn grid_min_content_flex_single_item_margin_percent__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 38f32, "height of node {:?}. Expected {}. Actual {}", node1, 38f32, size.height); - assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node1, 42f32, location.x); - assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node1, 1f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 38f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 38f32, layout.size.height); + } + if layout.location.x != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 42f32, layout.location.x); + } + if layout.location.y != 1f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 1f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node4, 28f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node4, 32f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); - assert_eq!(location.y, 42f32, "y of node {:?}. Expected {}. Actual {}", node4, 42f32, location.y); + if layout.size.width != 28f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 28f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 42f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_maximum_single_item.rs b/tests/generated/grid/grid_min_content_maximum_single_item.rs index 2d6289a7d..83385d1e2 100644 --- a/tests/generated/grid/grid_min_content_maximum_single_item.rs +++ b/tests/generated/grid/grid_min_content_maximum_single_item.rs @@ -4,24 +4,74 @@ fn grid_min_content_maximum_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(0f32), min_content()), length(40f32)], ..Default::default() @@ -33,66 +83,398 @@ fn grid_min_content_maximum_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,40 +484,83 @@ fn grid_min_content_maximum_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(0f32), min_content()), length(40f32)], ..Default::default() @@ -147,64 +572,396 @@ fn grid_min_content_maximum_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_min_content_single_item.rs b/tests/generated/grid/grid_min_content_single_item.rs index fce8b683e..62a75d454 100644 --- a/tests/generated/grid/grid_min_content_single_item.rs +++ b/tests/generated/grid/grid_min_content_single_item.rs @@ -4,24 +4,74 @@ fn grid_min_content_single_item__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), length(40f32)], ..Default::default() @@ -33,66 +83,398 @@ fn grid_min_content_single_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -102,40 +484,83 @@ fn grid_min_content_single_item__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), min_content(), length(40f32)], ..Default::default() @@ -147,64 +572,396 @@ fn grid_min_content_single_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_auto_fixed_10px.rs b/tests/generated/grid/grid_minmax_auto_fixed_10px.rs index 15355aa61..48d4c98e9 100644 --- a/tests/generated/grid/grid_minmax_auto_fixed_10px.rs +++ b/tests/generated/grid/grid_minmax_auto_fixed_10px.rs @@ -6,7 +6,13 @@ fn grid_minmax_auto_fixed_10px__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_auto_fixed_10px__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), length(10f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_auto_fixed_10px__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_auto_fixed_10px__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_auto_fixed_10px__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), length(10f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_auto_fixed_10px__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_auto_max_content.rs b/tests/generated/grid/grid_minmax_auto_max_content.rs index 0154dfe17..3a6ad8533 100644 --- a/tests/generated/grid/grid_minmax_auto_max_content.rs +++ b/tests/generated/grid/grid_minmax_auto_max_content.rs @@ -6,7 +6,13 @@ fn grid_minmax_auto_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_auto_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), max_content())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_auto_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_auto_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_auto_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), max_content())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_auto_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_auto_min_content.rs b/tests/generated/grid/grid_minmax_auto_min_content.rs index 88e3e819f..a931df8ca 100644 --- a/tests/generated/grid/grid_minmax_auto_min_content.rs +++ b/tests/generated/grid/grid_minmax_auto_min_content.rs @@ -6,7 +6,13 @@ fn grid_minmax_auto_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_auto_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), min_content())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_auto_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_auto_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_auto_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), min_content())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_auto_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_auto_percent_definite.rs b/tests/generated/grid/grid_minmax_auto_percent_definite.rs index ba60af09c..eb970cf18 100644 --- a/tests/generated/grid/grid_minmax_auto_percent_definite.rs +++ b/tests/generated/grid/grid_minmax_auto_percent_definite.rs @@ -6,7 +6,13 @@ fn grid_minmax_auto_percent_definite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_auto_percent_definite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_minmax_auto_percent_definite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_minmax_auto_percent_definite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_minmax_auto_percent_definite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_minmax_auto_percent_definite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs b/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs index a4bed242b..64ff629a2 100644 --- a/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs +++ b/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs @@ -6,7 +6,13 @@ fn grid_minmax_auto_percent_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_auto_percent_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), percent(0.2f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_auto_percent_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 8f32, "width of node {:?}. Expected {}. Actual {}", node0, 8f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 8f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 12f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 12f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_auto_percent_indefinite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_auto_percent_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(auto(), percent(0.2f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_auto_percent_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 8f32, "width of node {:?}. Expected {}. Actual {}", node0, 8f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 8f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 12f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 12f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs b/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs index 39b278a97..0aca43dec 100644 --- a/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs +++ b/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs @@ -4,19 +4,68 @@ fn grid_minmax_column_fixed_width_above_range__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(140f32), height: auto() }, @@ -29,66 +78,398 @@ fn grid_minmax_column_fixed_width_above_range__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,37 +479,77 @@ fn grid_minmax_column_fixed_width_above_range__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(140f32), height: auto() }, @@ -141,64 +562,396 @@ fn grid_minmax_column_fixed_width_above_range__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs b/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs index ba4167986..5219cd24b 100644 --- a/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs +++ b/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs @@ -4,19 +4,68 @@ fn grid_minmax_column_fixed_width_below_range__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(90f32), height: auto() }, @@ -29,66 +78,398 @@ fn grid_minmax_column_fixed_width_below_range__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,37 +479,77 @@ fn grid_minmax_column_fixed_width_below_range__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(90f32), height: auto() }, @@ -141,64 +562,396 @@ fn grid_minmax_column_fixed_width_below_range__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 90f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 90f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 10f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs b/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs index c7fb0e674..782d05363 100644 --- a/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs +++ b/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs @@ -4,19 +4,68 @@ fn grid_minmax_column_fixed_width_within_range__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), height: auto() }, @@ -29,66 +78,398 @@ fn grid_minmax_column_fixed_width_within_range__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node8, 70f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -98,37 +479,77 @@ fn grid_minmax_column_fixed_width_within_range__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(110f32), height: auto() }, @@ -141,64 +562,396 @@ fn grid_minmax_column_fixed_width_within_range__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 110f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 110f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node8, 70f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_indefinite.rs b/tests/generated/grid/grid_minmax_column_indefinite.rs index 0191460a7..b1861ee8a 100644 --- a/tests/generated/grid/grid_minmax_column_indefinite.rs +++ b/tests/generated/grid/grid_minmax_column_indefinite.rs @@ -4,19 +4,68 @@ fn grid_minmax_column_indefinite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], ..Default::default() @@ -28,66 +77,398 @@ fn grid_minmax_column_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -97,37 +478,77 @@ fn grid_minmax_column_indefinite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], ..Default::default() @@ -139,64 +560,396 @@ fn grid_minmax_column_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs b/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs index 08b83fed2..f73109f82 100644 --- a/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs +++ b/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs @@ -4,12 +4,26 @@ fn grid_minmax_column_with_auto_fixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(length(20f32), length(40f32)), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -22,24 +36,125 @@ fn grid_minmax_column_with_auto_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,16 +164,28 @@ fn grid_minmax_column_with_auto_fixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(length(20f32), length(40f32)), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -71,22 +198,123 @@ fn grid_minmax_column_with_auto_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs b/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs index 325f63bbf..326614c6c 100644 --- a/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs +++ b/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs @@ -4,12 +4,26 @@ fn grid_minmax_column_with_fr_fixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(length(20f32), length(40f32)), fr(1f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -22,24 +36,125 @@ fn grid_minmax_column_with_fr_fixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,16 +164,28 @@ fn grid_minmax_column_with_fr_fixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(length(20f32), length(40f32)), fr(1f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(60f32), height: auto() }, @@ -71,22 +198,123 @@ fn grid_minmax_column_with_fr_fixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_1fr.rs b/tests/generated/grid/grid_minmax_max_content_1fr.rs index 0e4b02af8..3dd5e089c 100644 --- a/tests/generated/grid/grid_minmax_max_content_1fr.rs +++ b/tests/generated/grid/grid_minmax_max_content_1fr.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_1fr__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_1fr__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), fr(1f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_max_content_1fr__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_max_content_1fr__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_max_content_1fr__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), fr(1f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_max_content_1fr__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_auto.rs b/tests/generated/grid/grid_minmax_max_content_auto.rs index 2cc3b4c31..8522b1a28 100644 --- a/tests/generated/grid/grid_minmax_max_content_auto.rs +++ b/tests/generated/grid/grid_minmax_max_content_auto.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_auto__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_auto__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), auto())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_max_content_auto__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_max_content_auto__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_max_content_auto__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), auto())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_max_content_auto__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs b/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs index 39dd901f5..dd20a9969 100644 --- a/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs +++ b/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_fixed_10px__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_fixed_10px__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), length(10f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_max_content_fixed_10px__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_max_content_fixed_10px__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_max_content_fixed_10px__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), length(10f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_max_content_fixed_10px__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_min_content.rs b/tests/generated/grid/grid_minmax_max_content_min_content.rs index c96ffc88c..10b0927ac 100644 --- a/tests/generated/grid/grid_minmax_max_content_min_content.rs +++ b/tests/generated/grid/grid_minmax_max_content_min_content.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_min_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_min_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), min_content())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_max_content_min_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_max_content_min_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_max_content_min_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), min_content())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_max_content_min_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_percent_definite.rs b/tests/generated/grid/grid_minmax_max_content_percent_definite.rs index 4e9d7d0d0..fc626e094 100644 --- a/tests/generated/grid/grid_minmax_max_content_percent_definite.rs +++ b/tests/generated/grid/grid_minmax_max_content_percent_definite.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_percent_definite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_percent_definite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_minmax_max_content_percent_definite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_minmax_max_content_percent_definite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_minmax_max_content_percent_definite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_minmax_max_content_percent_definite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs b/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs index 2258bb277..937ed1dbd 100644 --- a/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs +++ b/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs @@ -6,7 +6,13 @@ fn grid_minmax_max_content_percent_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_max_content_percent_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_max_content_percent_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_max_content_percent_indefinite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_max_content_percent_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_max_content_percent_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_1fr.rs b/tests/generated/grid/grid_minmax_min_content_1fr.rs index e97cf73b0..b0e67857a 100644 --- a/tests/generated/grid/grid_minmax_min_content_1fr.rs +++ b/tests/generated/grid/grid_minmax_min_content_1fr.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_1fr__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_1fr__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), fr(1f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_min_content_1fr__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_min_content_1fr__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_min_content_1fr__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), fr(1f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_min_content_1fr__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_auto.rs b/tests/generated/grid/grid_minmax_min_content_auto.rs index db7d772de..8982c3c2a 100644 --- a/tests/generated/grid/grid_minmax_min_content_auto.rs +++ b/tests/generated/grid/grid_minmax_min_content_auto.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_auto__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_auto__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), auto())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_min_content_auto__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_min_content_auto__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_min_content_auto__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), auto())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_min_content_auto__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs b/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs index 8162c00bf..6af7e40ad 100644 --- a/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs +++ b/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_fixed_10px__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_fixed_10px__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), length(10f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_min_content_fixed_10px__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_min_content_fixed_10px__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_min_content_fixed_10px__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), length(10f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_min_content_fixed_10px__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_max_content.rs b/tests/generated/grid/grid_minmax_min_content_max_content.rs index d3b77b7c4..ff4b15cff 100644 --- a/tests/generated/grid/grid_minmax_min_content_max_content.rs +++ b/tests/generated/grid/grid_minmax_min_content_max_content.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_max_content__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_max_content__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), max_content())], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_min_content_max_content__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_min_content_max_content__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_min_content_max_content__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), max_content())], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_min_content_max_content__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_percent_definite.rs b/tests/generated/grid/grid_minmax_min_content_percent_definite.rs index 06e02c573..43f8fbb4c 100644 --- a/tests/generated/grid/grid_minmax_min_content_percent_definite.rs +++ b/tests/generated/grid/grid_minmax_min_content_percent_definite.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_percent_definite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_percent_definite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -26,18 +36,86 @@ fn grid_minmax_min_content_percent_definite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -48,7 +126,14 @@ fn grid_minmax_min_content_percent_definite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -57,6 +142,10 @@ fn grid_minmax_min_content_percent_definite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() }, @@ -69,16 +158,84 @@ fn grid_minmax_min_content_percent_definite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs b/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs index 5b1add8a5..0bbc5b322 100644 --- a/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs +++ b/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs @@ -6,7 +6,13 @@ fn grid_minmax_min_content_percent_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_minmax_min_content_percent_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], ..Default::default() @@ -25,18 +35,86 @@ fn grid_minmax_min_content_percent_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -47,7 +125,14 @@ fn grid_minmax_min_content_percent_indefinite__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -56,6 +141,10 @@ fn grid_minmax_min_content_percent_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], ..Default::default() @@ -67,16 +156,84 @@ fn grid_minmax_min_content_percent_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_out_of_order_items.rs b/tests/generated/grid/grid_out_of_order_items.rs index 9511a1c4c..70b12bbb2 100644 --- a/tests/generated/grid/grid_out_of_order_items.rs +++ b/tests/generated/grid/grid_out_of_order_items.rs @@ -4,10 +4,21 @@ fn grid_out_of_order_items__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(35f32), @@ -16,10 +27,21 @@ fn grid_out_of_order_items__border_box() { ..Default::default() }) .unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -29,9 +51,15 @@ fn grid_out_of_order_items__border_box() { ..Default::default() }) .unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -40,11 +68,20 @@ fn grid_out_of_order_items__border_box() { ..Default::default() }) .unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], grid_auto_flow: taffy::style::GridAutoFlow::RowDense, @@ -61,66 +98,398 @@ fn grid_out_of_order_items__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node2, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node2, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node7, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node7, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -130,14 +499,23 @@ fn grid_out_of_order_items__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(35f32), @@ -147,14 +525,23 @@ fn grid_out_of_order_items__content_box() { }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -165,11 +552,16 @@ fn grid_out_of_order_items__content_box() { }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), @@ -179,13 +571,21 @@ fn grid_out_of_order_items__content_box() { }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], grid_auto_flow: taffy::style::GridAutoFlow::RowDense, @@ -202,64 +602,396 @@ fn grid_out_of_order_items__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node2, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node2, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node7, 10f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node7, 10f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_inline_axis_hidden.rs b/tests/generated/grid/grid_overflow_inline_axis_hidden.rs index 2002b9143..a03553fbc 100644 --- a/tests/generated/grid/grid_overflow_inline_axis_hidden.rs +++ b/tests/generated/grid/grid_overflow_inline_axis_hidden.rs @@ -21,6 +21,10 @@ fn grid_overflow_inline_axis_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,36 +38,86 @@ fn grid_overflow_inline_axis_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +145,10 @@ fn grid_overflow_inline_axis_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,34 +162,84 @@ fn grid_overflow_inline_axis_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 50f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 50f32, - layout.scroll_width() - ); + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_inline_axis_scroll.rs b/tests/generated/grid/grid_overflow_inline_axis_scroll.rs index d7f764775..8d7e11be2 100644 --- a/tests/generated/grid/grid_overflow_inline_axis_scroll.rs +++ b/tests/generated/grid/grid_overflow_inline_axis_scroll.rs @@ -21,6 +21,10 @@ fn grid_overflow_inline_axis_scroll__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -34,36 +38,86 @@ fn grid_overflow_inline_axis_scroll__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -91,6 +145,10 @@ fn grid_overflow_inline_axis_scroll__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -104,34 +162,84 @@ fn grid_overflow_inline_axis_scroll__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 65f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 65f32, - layout.scroll_width() - ); + if layout.scroll_width() != 65f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 65f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_inline_axis_visible.rs b/tests/generated/grid/grid_overflow_inline_axis_visible.rs index 06950762c..1e720520f 100644 --- a/tests/generated/grid/grid_overflow_inline_axis_visible.rs +++ b/tests/generated/grid/grid_overflow_inline_axis_visible.rs @@ -6,7 +6,13 @@ fn grid_overflow_inline_axis_visible__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -14,6 +20,10 @@ fn grid_overflow_inline_axis_visible__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -27,18 +37,86 @@ fn grid_overflow_inline_axis_visible__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -49,7 +127,14 @@ fn grid_overflow_inline_axis_visible__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -58,6 +143,10 @@ fn grid_overflow_inline_axis_visible__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: taffy::style::Dimension::from_length(50f32), @@ -71,16 +160,84 @@ fn grid_overflow_inline_axis_visible__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 50f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 50f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_rows.rs b/tests/generated/grid/grid_overflow_rows.rs index 981e7b095..f5ffdec32 100644 --- a/tests/generated/grid/grid_overflow_rows.rs +++ b/tests/generated/grid/grid_overflow_rows.rs @@ -7,6 +7,10 @@ fn grid_overflow_rows__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, ..Default::default() }, @@ -16,15 +20,44 @@ fn grid_overflow_rows__border_box() { ), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![min_content(), max_content(), length(10f32), percent(0.2f32)], ..Default::default() @@ -36,48 +69,281 @@ fn grid_overflow_rows__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node1, 43f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 43f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 203f32, "width of node {:?}. Expected {}. Actual {}", node2, 203f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 43f32, "x of node {:?}. Expected {}. Actual {}", node2, 43f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 203f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 203f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 43f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 246f32, "x of node {:?}. Expected {}. Actual {}", node3, 246f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 246f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 246f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node4, 64f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 256f32, "x of node {:?}. Expected {}. Actual {}", node4, 256f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 64f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 256f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node5, 43f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 43f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,6 +356,10 @@ fn grid_overflow_rows__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, ..Default::default() }, @@ -100,25 +370,49 @@ fn grid_overflow_rows__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![min_content(), max_content(), length(10f32), percent(0.2f32)], ..Default::default() @@ -130,46 +424,279 @@ fn grid_overflow_rows__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node1, 43f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 43f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 203f32, "width of node {:?}. Expected {}. Actual {}", node2, 203f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 43f32, "x of node {:?}. Expected {}. Actual {}", node2, 43f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 203f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 203f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 43f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 246f32, "x of node {:?}. Expected {}. Actual {}", node3, 246f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 246f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 246f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node4, 64f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 256f32, "x of node {:?}. Expected {}. Actual {}", node4, 256f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 64f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 256f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 256f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node5, 43f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); + if layout.size.width != 43f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 43f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs index a3b4db940..fd8ce9d69 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_overridden_by_available_space__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { @@ -23,6 +28,10 @@ fn grid_overflow_scrollbars_overridden_by_available_space__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -36,42 +45,125 @@ fn grid_overflow_scrollbars_overridden_by_available_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -81,7 +173,11 @@ fn grid_overflow_scrollbars_overridden_by_available_space__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node00 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -103,6 +199,10 @@ fn grid_overflow_scrollbars_overridden_by_available_space__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -116,40 +216,123 @@ fn grid_overflow_scrollbars_overridden_by_available_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs index e38d0b75f..49aafbb6b 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_overridden_by_max_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -27,36 +32,86 @@ fn grid_overflow_scrollbars_overridden_by_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,7 +121,11 @@ fn grid_overflow_scrollbars_overridden_by_max_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -91,34 +150,84 @@ fn grid_overflow_scrollbars_overridden_by_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs index 7996ec062..1a67b1983 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_overridden_by_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -27,36 +32,86 @@ fn grid_overflow_scrollbars_overridden_by_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,7 +121,11 @@ fn grid_overflow_scrollbars_overridden_by_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -91,34 +150,84 @@ fn grid_overflow_scrollbars_overridden_by_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs index efc16bdd2..b6738a754 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_take_up_space_both_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -27,36 +32,86 @@ fn grid_overflow_scrollbars_take_up_space_both_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,7 +121,11 @@ fn grid_overflow_scrollbars_take_up_space_both_axis__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -91,34 +150,84 @@ fn grid_overflow_scrollbars_take_up_space_both_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs index 17f6b266a..7d8978d28 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_take_up_space_x_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -27,36 +32,86 @@ fn grid_overflow_scrollbars_take_up_space_x_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,7 +121,11 @@ fn grid_overflow_scrollbars_take_up_space_x_axis__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -91,34 +150,84 @@ fn grid_overflow_scrollbars_take_up_space_x_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); - assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 35f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs index 6f2f45acd..a5166cb31 100644 --- a/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs +++ b/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs @@ -4,7 +4,12 @@ fn grid_overflow_scrollbars_take_up_space_y_axis__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -27,36 +32,86 @@ fn grid_overflow_scrollbars_take_up_space_y_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -66,7 +121,11 @@ fn grid_overflow_scrollbars_take_up_space_y_axis__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -91,34 +150,84 @@ fn grid_overflow_scrollbars_take_up_space_y_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs b/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs index ab998321b..3dcb6b130 100644 --- a/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs +++ b/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs @@ -4,11 +4,20 @@ fn grid_padding_border_overrides_container_max_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -34,18 +43,86 @@ fn grid_padding_border_overrides_container_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,13 +132,21 @@ fn grid_padding_border_overrides_container_max_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -87,16 +172,84 @@ fn grid_padding_border_overrides_container_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_padding_border_overrides_container_size.rs b/tests/generated/grid/grid_padding_border_overrides_container_size.rs index 76ae19fa3..d79769cf8 100644 --- a/tests/generated/grid/grid_padding_border_overrides_container_size.rs +++ b/tests/generated/grid/grid_padding_border_overrides_container_size.rs @@ -4,11 +4,20 @@ fn grid_padding_border_overrides_container_size__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -34,18 +43,86 @@ fn grid_padding_border_overrides_container_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,13 +132,21 @@ fn grid_padding_border_overrides_container_size__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -87,16 +172,84 @@ fn grid_padding_border_overrides_container_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 15f32, layout.location.x); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 3f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_padding_border_overrides_max_size.rs b/tests/generated/grid/grid_padding_border_overrides_max_size.rs index 4b598475c..812df080d 100644 --- a/tests/generated/grid/grid_padding_border_overrides_max_size.rs +++ b/tests/generated/grid/grid_padding_border_overrides_max_size.rs @@ -6,6 +6,7 @@ fn grid_padding_border_overrides_max_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -26,24 +27,102 @@ fn grid_padding_border_overrides_max_size__border_box() { }) .unwrap(); let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +134,7 @@ fn grid_padding_border_overrides_max_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -79,6 +159,10 @@ fn grid_padding_border_overrides_max_size__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -88,16 +172,84 @@ fn grid_padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_padding_border_overrides_min_size.rs b/tests/generated/grid/grid_padding_border_overrides_min_size.rs index df3768e82..8e426aec9 100644 --- a/tests/generated/grid/grid_padding_border_overrides_min_size.rs +++ b/tests/generated/grid/grid_padding_border_overrides_min_size.rs @@ -6,6 +6,7 @@ fn grid_padding_border_overrides_min_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -26,24 +27,102 @@ fn grid_padding_border_overrides_min_size__border_box() { }) .unwrap(); let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +134,7 @@ fn grid_padding_border_overrides_min_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -79,6 +159,10 @@ fn grid_padding_border_overrides_min_size__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -88,16 +172,84 @@ fn grid_padding_border_overrides_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_padding_border_overrides_size.rs b/tests/generated/grid/grid_padding_border_overrides_size.rs index 90c8c4352..b0a1f341e 100644 --- a/tests/generated/grid/grid_padding_border_overrides_size.rs +++ b/tests/generated/grid/grid_padding_border_overrides_size.rs @@ -6,6 +6,7 @@ fn grid_padding_border_overrides_size__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -26,24 +27,102 @@ fn grid_padding_border_overrides_size__border_box() { }) .unwrap(); let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -55,6 +134,7 @@ fn grid_padding_border_overrides_size__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -79,6 +159,10 @@ fn grid_padding_border_overrides_size__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -88,16 +172,84 @@ fn grid_padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node0, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_item_inside_stretch_item.rs b/tests/generated/grid/grid_percent_item_inside_stretch_item.rs index 22722692f..6e1c22c6e 100644 --- a/tests/generated/grid/grid_percent_item_inside_stretch_item.rs +++ b/tests/generated/grid/grid_percent_item_inside_stretch_item.rs @@ -7,13 +7,21 @@ fn grid_percent_item_inside_stretch_item__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -21,6 +29,10 @@ fn grid_percent_item_inside_stretch_item__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -34,24 +46,137 @@ fn grid_percent_item_inside_stretch_item__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -64,6 +189,7 @@ fn grid_percent_item_inside_stretch_item__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }) @@ -73,6 +199,10 @@ fn grid_percent_item_inside_stretch_item__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -83,6 +213,10 @@ fn grid_percent_item_inside_stretch_item__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -96,22 +230,135 @@ fn grid_percent_item_inside_stretch_item__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs b/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs index 2f978314f..685a88ef0 100644 --- a/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs +++ b/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs @@ -7,13 +7,21 @@ fn grid_percent_items_nested_inside_stretch_alignment__border_box() { let node00 = taffy .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: percent(0.2f32), bottom: zero() }, ..Default::default() }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node00], ) .unwrap(); @@ -21,6 +29,10 @@ fn grid_percent_items_nested_inside_stretch_alignment__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -31,24 +43,131 @@ fn grid_percent_items_nested_inside_stretch_alignment__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -61,6 +180,7 @@ fn grid_percent_items_nested_inside_stretch_alignment__content_box() { .new_leaf(taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, padding: taffy::geometry::Rect { left: zero(), right: zero(), top: percent(0.2f32), bottom: zero() }, ..Default::default() }) @@ -70,6 +190,10 @@ fn grid_percent_items_nested_inside_stretch_alignment__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node00], @@ -80,6 +204,10 @@ fn grid_percent_items_nested_inside_stretch_alignment__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -90,22 +218,129 @@ fn grid_percent_items_nested_inside_stretch_alignment__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_nested_moderate.rs b/tests/generated/grid/grid_percent_items_nested_moderate.rs index af6820594..efaee2bff 100644 --- a/tests/generated/grid/grid_percent_items_nested_moderate.rs +++ b/tests/generated/grid/grid_percent_items_nested_moderate.rs @@ -7,6 +7,7 @@ fn grid_percent_items_nested_moderate__border_box() { taffy.disable_rounding(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -27,6 +28,10 @@ fn grid_percent_items_nested_moderate__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -49,6 +54,10 @@ fn grid_percent_items_nested_moderate__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -65,54 +74,155 @@ fn grid_percent_items_nested_moderate__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 200f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert!( - (size.height - 42.15625f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node, - 42.15625f32, - size.height - ); - assert!((location.x - 0f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert!((location.y - 0f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if (layout.size.width - 200f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if (layout.size.height - 42.15625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(size.height), + 42.15625f32, + layout.size.height + ); + } + if (layout.location.x - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if (layout.location.y - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 97f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 97f32, size.width); - assert!( - (size.height - 26.15625f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node0, - 26.15625f32, - size.height - ); - assert!((location.x - 8f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert!((location.y - 8f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if (layout.size.width - 97f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 97f32, layout.size.width); + } + if (layout.size.height - 26.15625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 26.15625f32, + layout.size.height + ); + } + if (layout.location.x - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if (layout.location.y - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert!( - (size.width - 38.40625f32).abs() < 0.1, - "width of node {:?}. Expected {}. Actual {}", - node00, - 38.40625f32, - size.width - ); - assert!((size.height - 6f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); - assert!( - (location.x - 10.078125f32).abs() < 0.1, - "x of node {:?}. Expected {}. Actual {}", - node00, - 10.078125f32, - location.x - ); - assert!( - (location.y - 10.078125f32).abs() < 0.1, - "y of node {:?}. Expected {}. Actual {}", - node00, - 10.078125f32, - location.y - ); + if (layout.size.width - 38.40625f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.width), + 38.40625f32, + layout.size.width + ); + } + if (layout.size.height - 6f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 6f32, layout.size.height); + } + if (layout.location.x - 10.078125f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(location.x), + 10.078125f32, + layout.location.x + ); + } + if (layout.location.y - 10.078125f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(location.y), + 10.078125f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -125,6 +235,7 @@ fn grid_percent_items_nested_moderate__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -146,6 +257,10 @@ fn grid_percent_items_nested_moderate__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -169,6 +284,10 @@ fn grid_percent_items_nested_moderate__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -185,28 +304,123 @@ fn grid_percent_items_nested_moderate__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 206f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 206f32, size.width); - assert!((size.height - 44f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node, 44f32, size.height); - assert!((location.x - 0f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert!((location.y - 0f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if (layout.size.width - 206f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 206f32, layout.size.width); + } + if (layout.size.height - 44f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 44f32, layout.size.height); + } + if (layout.location.x - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if (layout.location.y - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 112f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 112f32, size.width); - assert!( - (size.height - 28f32).abs() < 0.1, - "height of node {:?}. Expected {}. Actual {}", - node0, - 28f32, - size.height - ); - assert!((location.x - 8f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); - assert!((location.y - 8f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); + if (layout.size.width - 112f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 112f32, layout.size.width); + } + if (layout.size.height - 28f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 28f32, layout.size.height); + } + if (layout.location.x - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 8f32, layout.location.x); + } + if (layout.location.y - 8f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert!((size.width - 51f32).abs() < 0.1, "width of node {:?}. Expected {}. Actual {}", node00, 51f32, size.width); - assert!((size.height - 6f32).abs() < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); - assert!((location.x - 11f32).abs() < 0.1, "x of node {:?}. Expected {}. Actual {}", node00, 11f32, location.x); - assert!((location.y - 11f32).abs() < 0.1, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); + if (layout.size.width - 51f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 51f32, layout.size.width); + } + if (layout.size.height - 6f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 6f32, layout.size.height); + } + if (layout.location.x - 11f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 11f32, layout.location.x); + } + if (layout.location.y - 11f32).abs() >= 0.1 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 11f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if (layout.scroll_width() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if (layout.scroll_height() - 0f32).abs() >= 0.1 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_nested_with_margin.rs b/tests/generated/grid/grid_percent_items_nested_with_margin.rs index d4a54da7c..48c399845 100644 --- a/tests/generated/grid/grid_percent_items_nested_with_margin.rs +++ b/tests/generated/grid/grid_percent_items_nested_with_margin.rs @@ -6,6 +6,7 @@ fn grid_percent_items_nested_with_margin__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -20,6 +21,10 @@ fn grid_percent_items_nested_with_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -30,6 +35,10 @@ fn grid_percent_items_nested_with_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -40,24 +49,125 @@ fn grid_percent_items_nested_with_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node00, 45f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -69,6 +179,7 @@ fn grid_percent_items_nested_with_margin__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -84,6 +195,10 @@ fn grid_percent_items_nested_with_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, ..Default::default() }, @@ -95,6 +210,10 @@ fn grid_percent_items_nested_with_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -105,22 +224,123 @@ fn grid_percent_items_nested_with_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node00, 45f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs b/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs index 94701c10a..4865a3fef 100644 --- a/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs +++ b/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs @@ -6,6 +6,7 @@ fn grid_percent_items_nested_with_padding_margin__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -26,6 +27,10 @@ fn grid_percent_items_nested_with_padding_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -48,6 +53,10 @@ fn grid_percent_items_nested_with_padding_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto(), @@ -69,11 +78,20 @@ fn grid_percent_items_nested_with_padding_margin__border_box() { &[node00], ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(4f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -88,36 +106,221 @@ fn grid_percent_items_nested_with_padding_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); - assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node0, 41f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 41f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 41f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node00, 92f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node00, 25f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); + if layout.size.width != 92f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 92f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 25f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node000, 36f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 6f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 149f32, "height of node {:?}. Expected {}. Actual {}", node1, 149f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 51f32, "y of node {:?}. Expected {}. Actual {}", node1, 51f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 149f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 149f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 51f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -129,6 +332,7 @@ fn grid_percent_items_nested_with_padding_margin__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -150,6 +354,10 @@ fn grid_percent_items_nested_with_padding_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: length(5f32), @@ -173,6 +381,10 @@ fn grid_percent_items_nested_with_padding_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.6f32), height: auto(), @@ -195,13 +407,21 @@ fn grid_percent_items_nested_with_padding_margin__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(4f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -216,34 +436,219 @@ fn grid_percent_items_nested_with_padding_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); - assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); - assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); - assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); + if layout.size.width != 190f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 190f32, layout.size.width); + } + if layout.size.height != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 42f32, layout.size.height); + } + if layout.location.x != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 5f32, layout.location.x); + } + if layout.location.y != 5f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 5f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 103f32, "width of node {:?}. Expected {}. Actual {}", node00, 103f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node00, 26f32, size.height); - assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); - assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); + if layout.size.width != 103f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 103f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 26f32, + layout.size.height + ); + } + if layout.location.x != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 8f32, layout.location.x); + } + if layout.location.y != 8f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 8f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node000, 48f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 6f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); - assert_eq!(size.height, 148f32, "height of node {:?}. Expected {}. Actual {}", node1, 148f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node1, 52f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 148f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(size.height), + 148f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 52f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_width_and_margin.rs b/tests/generated/grid/grid_percent_items_width_and_margin.rs index fa891a972..02914a3f7 100644 --- a/tests/generated/grid/grid_percent_items_width_and_margin.rs +++ b/tests/generated/grid/grid_percent_items_width_and_margin.rs @@ -6,6 +6,7 @@ fn grid_percent_items_width_and_margin__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -26,6 +27,10 @@ fn grid_percent_items_width_and_margin__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -42,18 +47,86 @@ fn grid_percent_items_width_and_margin__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 31f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 31f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node0, 6f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); + if layout.size.width != 87f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 87f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 6f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -65,6 +138,7 @@ fn grid_percent_items_width_and_margin__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.45f32), height: auto() }, margin: taffy::geometry::Rect { left: percent(0.05f32), @@ -86,6 +160,10 @@ fn grid_percent_items_width_and_margin__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: length(3f32), @@ -102,16 +180,84 @@ fn grid_percent_items_width_and_margin__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 206f32, "width of node {:?}. Expected {}. Actual {}", node, 206f32, size.width); - assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node, 32f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 206f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 206f32, layout.size.width); + } + if layout.size.height != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 32f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 96f32, "width of node {:?}. Expected {}. Actual {}", node0, 96f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node0, 6f32, size.height); - assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); - assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); + if layout.size.width != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 96f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 6f32, layout.size.height); + } + if layout.location.x != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 13f32, layout.location.x); + } + if layout.location.y != 13f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 13f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_items_width_and_padding.rs b/tests/generated/grid/grid_percent_items_width_and_padding.rs index 92b38cae3..ebee4562e 100644 --- a/tests/generated/grid/grid_percent_items_width_and_padding.rs +++ b/tests/generated/grid/grid_percent_items_width_and_padding.rs @@ -6,6 +6,7 @@ fn grid_percent_items_width_and_padding__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, padding: taffy::geometry::Rect { left: percent(0.03f32), @@ -20,6 +21,10 @@ fn grid_percent_items_width_and_padding__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -30,18 +35,86 @@ fn grid_percent_items_width_and_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -53,6 +126,7 @@ fn grid_percent_items_width_and_padding__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_percent(0.5f32), height: auto() }, padding: taffy::geometry::Rect { left: percent(0.03f32), @@ -68,6 +142,10 @@ fn grid_percent_items_width_and_padding__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() }, ..Default::default() }, @@ -78,16 +156,84 @@ fn grid_percent_items_width_and_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 112f32, "width of node {:?}. Expected {}. Actual {}", node0, 112f32, size.width); - assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 112f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 112f32, layout.size.width); + } + if layout.size.height != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 12f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_tracks_definite_overflow.rs b/tests/generated/grid/grid_percent_tracks_definite_overflow.rs index 19b6ace1f..7f117ac04 100644 --- a/tests/generated/grid/grid_percent_tracks_definite_overflow.rs +++ b/tests/generated/grid/grid_percent_tracks_definite_overflow.rs @@ -4,16 +4,50 @@ fn grid_percent_tracks_definite_overflow__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], size: taffy::geometry::Size { @@ -29,48 +63,281 @@ fn grid_percent_tracks_definite_overflow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 24f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 18f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 18f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node0, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node1, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node2, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node2, 96f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node3, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node3, 48f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node4, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node4, 48f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node5, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node5, 48f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node5, 96f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,28 +347,56 @@ fn grid_percent_tracks_definite_overflow__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], size: taffy::geometry::Size { @@ -117,46 +412,279 @@ fn grid_percent_tracks_definite_overflow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 24f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 24f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 18f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 18f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node0, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node1, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node2, 48f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node2, 96f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node3, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node3, 48f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node4, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node4, 48f32, size.height); - assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 48f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node5, 48f32, size.width); - assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node5, 48f32, size.height); - assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node5, 96f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 48f32, layout.size.width); + } + if layout.size.height != 48f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 48f32, layout.size.height); + } + if layout.location.x != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 96f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_tracks_definite_underflow.rs b/tests/generated/grid/grid_percent_tracks_definite_underflow.rs index 3418ead1a..c8eedbeac 100644 --- a/tests/generated/grid/grid_percent_tracks_definite_underflow.rs +++ b/tests/generated/grid/grid_percent_tracks_definite_underflow.rs @@ -4,16 +4,50 @@ fn grid_percent_tracks_definite_underflow__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], size: taffy::geometry::Size { @@ -29,48 +63,281 @@ fn grid_percent_tracks_definite_underflow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node0, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node1, 18f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node1, 12f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node2, 18f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node2, 36f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 36f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node3, 12f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node3, 36f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node3, 18f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node4, 24f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node4, 36f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node4, 12f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node4, 18f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node5, 36f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node5, 36f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node5, 36f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node5, 18f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 36f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -80,28 +347,56 @@ fn grid_percent_tracks_definite_underflow__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], size: taffy::geometry::Size { @@ -117,46 +412,279 @@ fn grid_percent_tracks_definite_underflow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node0, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node1, 18f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node1, 12f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node2, 18f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node2, 36f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 36f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node3, 12f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node3, 36f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node3, 18f32, location.y); + if layout.size.width != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 12f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node4, 24f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node4, 36f32, size.height); - assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node4, 12f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node4, 18f32, location.y); + if layout.size.width != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 24f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 12f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 12f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node5, 36f32, size.width); - assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node5, 36f32, size.height); - assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node5, 36f32, location.x); - assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node5, 18f32, location.y); + if layout.size.width != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 36f32, layout.size.width); + } + if layout.size.height != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 36f32, layout.size.height); + } + if layout.location.x != 36f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 36f32, layout.location.x); + } + if layout.location.y != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 18f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_tracks_indefinite_only.rs b/tests/generated/grid/grid_percent_tracks_indefinite_only.rs index f73bee0e7..7b2caf8b5 100644 --- a/tests/generated/grid/grid_percent_tracks_indefinite_only.rs +++ b/tests/generated/grid/grid_percent_tracks_indefinite_only.rs @@ -4,16 +4,50 @@ fn grid_percent_tracks_indefinite_only__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], ..Default::default() @@ -25,48 +59,281 @@ fn grid_percent_tracks_indefinite_only__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -76,28 +343,56 @@ fn grid_percent_tracks_indefinite_only__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], ..Default::default() @@ -109,46 +404,279 @@ fn grid_percent_tracks_indefinite_only__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); - assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 0f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs b/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs index c30dcac72..55e4160b4 100644 --- a/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs +++ b/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs @@ -6,6 +6,7 @@ fn grid_percent_tracks_indefinite_with_content_overflow__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,20 +18,50 @@ fn grid_percent_tracks_indefinite_with_content_overflow__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], ..Default::default() @@ -42,54 +73,326 @@ fn grid_percent_tracks_indefinite_with_content_overflow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 30f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +404,7 @@ fn grid_percent_tracks_indefinite_with_content_overflow__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -113,31 +417,56 @@ fn grid_percent_tracks_indefinite_with_content_overflow__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], ..Default::default() @@ -149,52 +478,324 @@ fn grid_percent_tracks_indefinite_with_content_overflow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 20f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 30f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 30f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs b/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs index 69bc11ce7..b7fb539bb 100644 --- a/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs +++ b/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs @@ -6,6 +6,7 @@ fn grid_percent_tracks_indefinite_with_content_underflow__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,20 +18,50 @@ fn grid_percent_tracks_indefinite_with_content_underflow__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], ..Default::default() @@ -42,54 +73,326 @@ fn grid_percent_tracks_indefinite_with_content_underflow__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node5, 10f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node6, 30f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node6, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node6, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +404,7 @@ fn grid_percent_tracks_indefinite_with_content_underflow__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -113,31 +417,56 @@ fn grid_percent_tracks_indefinite_with_content_underflow__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], ..Default::default() @@ -149,52 +478,324 @@ fn grid_percent_tracks_indefinite_with_content_underflow__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node5, 10f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node6, 30f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node6, 30f32, location.x); - assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node6, 30f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 30f32, layout.location.x); + } + if layout.location.y != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 30f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_placement_auto_negative.rs b/tests/generated/grid/grid_placement_auto_negative.rs index 2671b06f4..b64855aaf 100644 --- a/tests/generated/grid/grid_placement_auto_negative.rs +++ b/tests/generated/grid/grid_placement_auto_negative.rs @@ -6,14 +6,21 @@ fn grid_placement_auto_negative__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(-5i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -22,6 +29,10 @@ fn grid_placement_auto_negative__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -37,30 +48,164 @@ fn grid_placement_auto_negative__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -72,17 +217,23 @@ fn grid_placement_auto_negative__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(-5i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -92,6 +243,10 @@ fn grid_placement_auto_negative__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -107,28 +262,162 @@ fn grid_placement_auto_negative__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs b/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs index 24a7acee5..8182863f5 100644 --- a/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs +++ b/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs @@ -6,12 +6,14 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__borde let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -19,6 +21,7 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__borde .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -27,6 +30,10 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__borde .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -42,30 +49,164 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__borde println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -77,6 +218,7 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__conte let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -84,6 +226,7 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__conte let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -92,6 +235,7 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__conte let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -101,6 +245,10 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__conte taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -116,28 +264,162 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative__conte println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_placement_definite_primary.rs b/tests/generated/grid/grid_placement_definite_primary.rs index 0affc1bb0..bd025c5b9 100644 --- a/tests/generated/grid/grid_placement_definite_primary.rs +++ b/tests/generated/grid/grid_placement_definite_primary.rs @@ -6,30 +6,35 @@ fn grid_placement_definite_primary__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node3 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) .unwrap(); let node4 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -38,6 +43,10 @@ fn grid_placement_definite_primary__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![percent(0.33f32), percent(0.74f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -52,42 +61,242 @@ fn grid_placement_definite_primary__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 14f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node0, 66f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node1, 148f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node1, 67f32, size.height); - assert_eq!(location.x, 66f32, "x of node {:?}. Expected {}. Actual {}", node1, 66f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 66f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node2, 66f32, size.width); - assert_eq!(size.height, 66f32, "height of node {:?}. Expected {}. Actual {}", node2, 66f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node2, 67f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 66f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node3, 148f32, size.width); - assert_eq!(size.height, 66f32, "height of node {:?}. Expected {}. Actual {}", node3, 66f32, size.height); - assert_eq!(location.x, 66f32, "x of node {:?}. Expected {}. Actual {}", node3, 66f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node3, 67f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 66f32, layout.size.height); + } + if layout.location.x != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 66f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node4, 66f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node4, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 133f32, "y of node {:?}. Expected {}. Actual {}", node4, 133f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 133f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 133f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -99,6 +308,7 @@ fn grid_placement_definite_primary__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -106,6 +316,7 @@ fn grid_placement_definite_primary__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -113,6 +324,7 @@ fn grid_placement_definite_primary__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -120,6 +332,7 @@ fn grid_placement_definite_primary__content_box() { let node3 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -127,6 +340,7 @@ fn grid_placement_definite_primary__content_box() { let node4 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() }) @@ -136,6 +350,10 @@ fn grid_placement_definite_primary__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_columns: vec![percent(0.33f32), percent(0.74f32)], size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), @@ -150,40 +368,240 @@ fn grid_placement_definite_primary__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 200f32, layout.size.width); + } + if layout.size.height != 200f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 200f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 14f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 14f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node0, 66f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node1, 148f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node1, 67f32, size.height); - assert_eq!(location.x, 66f32, "x of node {:?}. Expected {}. Actual {}", node1, 66f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 66f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node2, 66f32, size.width); - assert_eq!(size.height, 66f32, "height of node {:?}. Expected {}. Actual {}", node2, 66f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node2, 67f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 66f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node3, 148f32, size.width); - assert_eq!(size.height, 66f32, "height of node {:?}. Expected {}. Actual {}", node3, 66f32, size.height); - assert_eq!(location.x, 66f32, "x of node {:?}. Expected {}. Actual {}", node3, 66f32, location.x); - assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node3, 67f32, location.y); + if layout.size.width != 148f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 148f32, layout.size.width); + } + if layout.size.height != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 66f32, layout.size.height); + } + if layout.location.x != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 66f32, layout.location.x); + } + if layout.location.y != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 67f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 66f32, "width of node {:?}. Expected {}. Actual {}", node4, 66f32, size.width); - assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node4, 67f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 133f32, "y of node {:?}. Expected {}. Actual {}", node4, 133f32, location.y); + if layout.size.width != 66f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 66f32, layout.size.width); + } + if layout.size.height != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 67f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 133f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 133f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_relative_all_sides.rs b/tests/generated/grid/grid_relative_all_sides.rs index 00ebcff0a..028576cbc 100644 --- a/tests/generated/grid/grid_relative_all_sides.rs +++ b/tests/generated/grid/grid_relative_all_sides.rs @@ -6,6 +6,7 @@ fn grid_relative_all_sides__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -20,6 +21,10 @@ fn grid_relative_all_sides__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -33,18 +38,92 @@ fn grid_relative_all_sides__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -56,6 +135,7 @@ fn grid_relative_all_sides__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() }, inset: taffy::geometry::Rect { left: length(10f32), @@ -71,6 +151,10 @@ fn grid_relative_all_sides__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: taffy::style::Dimension::from_length(100f32), @@ -84,16 +168,90 @@ fn grid_relative_all_sides__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 100f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 10f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 100f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(size.height), + 100f32, + layout.size.height + ); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_relayout_vertical_text.rs b/tests/generated/grid/grid_relayout_vertical_text.rs index 36c9a71a5..659e134d7 100644 --- a/tests/generated/grid/grid_relayout_vertical_text.rs +++ b/tests/generated/grid/grid_relayout_vertical_text.rs @@ -6,7 +6,13 @@ fn grid_relayout_vertical_text__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text( "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Vertical, @@ -15,7 +21,13 @@ fn grid_relayout_vertical_text__border_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -23,6 +35,10 @@ fn grid_relayout_vertical_text__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -34,24 +50,125 @@ fn grid_relayout_vertical_text__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,7 +179,14 @@ fn grid_relayout_vertical_text__content_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text( "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH", crate::WritingMode::Vertical, @@ -71,7 +195,14 @@ fn grid_relayout_vertical_text__content_box() { .unwrap(); let node1 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH\u{200b}HH\u{200b}HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -80,6 +211,10 @@ fn grid_relayout_vertical_text__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content()], ..Default::default() @@ -91,22 +226,123 @@ fn grid_relayout_vertical_text__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 60f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_repeat_integer.rs b/tests/generated/grid/grid_repeat_integer.rs index b1650dbe1..3ddf2d3e0 100644 --- a/tests/generated/grid/grid_repeat_integer.rs +++ b/tests/generated/grid/grid_repeat_integer.rs @@ -4,19 +4,68 @@ fn grid_repeat_integer__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![repeat(RepetitionCount::Count(3u16), vec![length(40f32)])], grid_template_columns: vec![repeat(RepetitionCount::Count(3u16), vec![length(40f32)])], size: taffy::geometry::Size { @@ -32,66 +81,398 @@ fn grid_repeat_integer__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,37 +482,77 @@ fn grid_repeat_integer__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![repeat(RepetitionCount::Count(3u16), vec![length(40f32)])], grid_template_columns: vec![repeat(RepetitionCount::Count(3u16), vec![length(40f32)])], size: taffy::geometry::Size { @@ -147,64 +568,396 @@ fn grid_repeat_integer__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_repeat_mixed.rs b/tests/generated/grid/grid_repeat_mixed.rs index 3a72d05d3..6873b2f39 100644 --- a/tests/generated/grid/grid_repeat_mixed.rs +++ b/tests/generated/grid/grid_repeat_mixed.rs @@ -4,19 +4,68 @@ fn grid_repeat_mixed__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![ length(40f32), repeat(RepetitionCount::Count(1u16), vec![length(40f32)]), @@ -40,66 +89,398 @@ fn grid_repeat_mixed__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -109,37 +490,77 @@ fn grid_repeat_mixed__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![ length(40f32), repeat(RepetitionCount::Count(1u16), vec![length(40f32)]), @@ -163,64 +584,396 @@ fn grid_repeat_mixed__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); - assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 80f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_size_child_fixed_tracks.rs b/tests/generated/grid/grid_size_child_fixed_tracks.rs index 5c0fd8ec5..18af00d94 100644 --- a/tests/generated/grid/grid_size_child_fixed_tracks.rs +++ b/tests/generated/grid/grid_size_child_fixed_tracks.rs @@ -7,6 +7,10 @@ fn grid_size_child_fixed_tracks__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -17,6 +21,10 @@ fn grid_size_child_fixed_tracks__border_box() { let node1 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -27,6 +35,10 @@ fn grid_size_child_fixed_tracks__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -37,6 +49,10 @@ fn grid_size_child_fixed_tracks__border_box() { let node3 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, @@ -48,6 +64,10 @@ fn grid_size_child_fixed_tracks__border_box() { let node4 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: auto() }, @@ -60,6 +80,10 @@ fn grid_size_child_fixed_tracks__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -75,42 +99,242 @@ fn grid_size_child_fixed_tracks__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -123,6 +347,10 @@ fn grid_size_child_fixed_tracks__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -134,6 +362,10 @@ fn grid_size_child_fixed_tracks__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -145,6 +377,10 @@ fn grid_size_child_fixed_tracks__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), ..Default::default() @@ -156,6 +392,10 @@ fn grid_size_child_fixed_tracks__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, @@ -168,6 +408,10 @@ fn grid_size_child_fixed_tracks__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, align_self: Some(taffy::style::AlignSelf::Start), justify_self: Some(taffy::style::JustifySelf::Start), max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(30f32), height: auto() }, @@ -181,6 +425,10 @@ fn grid_size_child_fixed_tracks__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { @@ -196,40 +444,240 @@ fn grid_size_child_fixed_tracks__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 120f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs b/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs index 39b571bec..6e0c7474b 100644 --- a/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs +++ b/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs @@ -7,6 +7,10 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, ..Default::default() }, @@ -16,23 +20,92 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__border_box() { ), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node11 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node12 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node13 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -58,96 +131,617 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node1, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node2, 91f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 11f32, "x of node {:?}. Expected {}. Actual {}", node2, 11f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 11f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node3, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 102f32, "x of node {:?}. Expected {}. Actual {}", node3, 102f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 102f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 102f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node4, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 113f32, "x of node {:?}. Expected {}. Actual {}", node4, 113f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 113f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 124f32, "x of node {:?}. Expected {}. Actual {}", node5, 124f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 124f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node6, 65f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node6, 134f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 134f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 134f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 199f32, "x of node {:?}. Expected {}. Actual {}", node7, 199f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 199f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 199f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 201f32, "x of node {:?}. Expected {}. Actual {}", node8, 201f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 201f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 201f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 205f32, "x of node {:?}. Expected {}. Actual {}", node9, 205f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 205f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 205f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 207f32, "x of node {:?}. Expected {}. Actual {}", node10, 207f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 207f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 207f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node11, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 209f32, "x of node {:?}. Expected {}. Actual {}", node11, 209f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 209f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 209f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node12, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); - assert_eq!(location.x, 220f32, "x of node {:?}. Expected {}. Actual {}", node12, 220f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 220f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 220f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node13, 91f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); - assert_eq!(location.x, 231f32, "x of node {:?}. Expected {}. Actual {}", node13, 231f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node13, 40f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 231f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 231f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -160,6 +754,10 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, ..Default::default() }, @@ -170,49 +768,105 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node9 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node11 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node12 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node13 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -238,94 +892,615 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node1, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node2, 91f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 11f32, "x of node {:?}. Expected {}. Actual {}", node2, 11f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 11f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node3, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 102f32, "x of node {:?}. Expected {}. Actual {}", node3, 102f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 102f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 102f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node4, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 113f32, "x of node {:?}. Expected {}. Actual {}", node4, 113f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 113f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 113f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 124f32, "x of node {:?}. Expected {}. Actual {}", node5, 124f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 124f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 124f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node6, 65f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node6, 134f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 65f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 65f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 134f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 134f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 199f32, "x of node {:?}. Expected {}. Actual {}", node7, 199f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 199f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 199f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 201f32, "x of node {:?}. Expected {}. Actual {}", node8, 201f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 201f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 201f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 205f32, "x of node {:?}. Expected {}. Actual {}", node9, 205f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 205f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 205f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 207f32, "x of node {:?}. Expected {}. Actual {}", node10, 207f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 207f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 207f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node11, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 209f32, "x of node {:?}. Expected {}. Actual {}", node11, 209f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 209f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 209f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node12, 11f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); - assert_eq!(location.x, 220f32, "x of node {:?}. Expected {}. Actual {}", node12, 220f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 11f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 11f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 220f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 220f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node13, 91f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); - assert_eq!(location.x, 231f32, "x of node {:?}. Expected {}. Actual {}", node13, 231f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node13, 40f32, location.y); + if layout.size.width != 91f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 91f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 231f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 231f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs b/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs index 046430049..d5282fa4a 100644 --- a/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs @@ -21,23 +21,92 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite_hidden__border_box() { ), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node11 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node12 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node13 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -63,114 +132,617 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 95f32, "width of node {:?}. Expected {}. Actual {}", node2, 95f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node2, 16f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 95f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 16f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node3, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node4, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node5, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node6, 64f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 121f32, "x of node {:?}. Expected {}. Actual {}", node6, 121f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 64f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 121f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 121f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 185f32, "x of node {:?}. Expected {}. Actual {}", node7, 185f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 185f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 185f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 187f32, "x of node {:?}. Expected {}. Actual {}", node8, 187f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 187f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 187f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 191f32, "x of node {:?}. Expected {}. Actual {}", node9, 191f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 191f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 191f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node10, 193f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 193f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 193f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node11, 16f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node11, 195f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node12, 15f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); - assert_eq!(location.x, 211f32, "x of node {:?}. Expected {}. Actual {}", node12, 211f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 211f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 211f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 96f32, "width of node {:?}. Expected {}. Actual {}", node13, 96f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); - assert_eq!(location.x, 226f32, "x of node {:?}. Expected {}. Actual {}", node13, 226f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node13, 40f32, location.y); + if layout.size.width != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 96f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 226f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 226f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -198,49 +770,105 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite_hidden__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node9 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node11 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node12 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node13 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -266,112 +894,615 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 322f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 322f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 95f32, "width of node {:?}. Expected {}. Actual {}", node2, 95f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node2, 16f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 95f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 95f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 16f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node3, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node4, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node5, 111f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 111f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 111f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node6, 64f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 121f32, "x of node {:?}. Expected {}. Actual {}", node6, 121f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 64f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 64f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 121f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 121f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 185f32, "x of node {:?}. Expected {}. Actual {}", node7, 185f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 185f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 185f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 187f32, "x of node {:?}. Expected {}. Actual {}", node8, 187f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 4f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 187f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 187f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node9).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); - assert_eq!(location.x, 191f32, "x of node {:?}. Expected {}. Actual {}", node9, 191f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 191f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.x), 191f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node9, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node9, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node10).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); - assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node10, 193f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 193f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.x), 193f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node10, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node10, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node11).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node11, 16f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); - assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node11, 195f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); + if layout.size.width != 16f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(size.width), 16f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 195f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.x), 195f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node11, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node11, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node12).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node12, 15f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); - assert_eq!(location.x, 211f32, "x of node {:?}. Expected {}. Actual {}", node12, 211f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + if layout.size.width != 15f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(size.width), 15f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 211f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.x), 211f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node12, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node12, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node13).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 96f32, "width of node {:?}. Expected {}. Actual {}", node13, 96f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); - assert_eq!(location.x, 226f32, "x of node {:?}. Expected {}. Actual {}", node13, 226f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node13, 40f32, location.y); + if layout.size.width != 96f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(size.width), 96f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(size.height), + 40f32, + layout.size.height + ); + } + if layout.location.x != 226f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.x), 226f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node13, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node13, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs b/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs index abf6864be..ebf17b889 100644 --- a/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs +++ b/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_auto_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_auto_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_max_content_auto_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_max_content_auto_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), auto()], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_max_content_auto_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_max_content_auto_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_max_content_auto_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_max_content_auto_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_max_content_auto_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), auto()], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_max_content_auto_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs index 5735bbfe1..614fb487f 100644 --- a/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_auto_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_auto_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -22,6 +24,10 @@ fn grid_span_2_max_content_auto_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), auto()], ..Default::default() @@ -33,24 +39,125 @@ fn grid_span_2_max_content_auto_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,6 +169,7 @@ fn grid_span_2_max_content_auto_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -70,6 +178,7 @@ fn grid_span_2_max_content_auto_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -80,6 +189,10 @@ fn grid_span_2_max_content_auto_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), auto()], ..Default::default() @@ -91,22 +204,123 @@ fn grid_span_2_max_content_auto_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs b/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs index b3d04f724..ca18be588 100644 --- a/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs +++ b/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_max_content_fit_content_10px_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs index a73c344fe..405b3079e 100644 --- a/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -37,6 +39,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() @@ -48,48 +54,164 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +223,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -109,6 +232,7 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -135,6 +259,10 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() @@ -146,46 +274,162 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs b/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs index 3af97e9cc..21ce9c1d5 100644 --- a/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs +++ b/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_max_content_fit_content_80px_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 60f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs index 2f09998cf..92b0e5147 100644 --- a/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -37,6 +39,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() @@ -48,48 +54,164 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +223,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -109,6 +232,7 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -135,6 +259,10 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() @@ -146,46 +274,162 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 80f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs b/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs index 8d556f073..02c7b119c 100644 --- a/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs +++ b/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_max_content_max_content_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_max_content_max_content_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_max_content_max_content_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_max_content_max_content_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), max_content()], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_max_content_max_content_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_max_content_max_content_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_max_content_max_content_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_max_content_max_content_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_max_content_max_content_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![max_content(), max_content()], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_max_content_max_content_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs index 6c84301c2..2e20640f4 100644 --- a/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs @@ -4,11 +4,25 @@ fn grid_span_2_min_content_auto_indefinite__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() }, @@ -19,6 +33,10 @@ fn grid_span_2_min_content_auto_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), auto()], ..Default::default() @@ -30,30 +48,164 @@ fn grid_span_2_min_content_auto_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -63,15 +215,27 @@ fn grid_span_2_min_content_auto_indefinite__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() }, @@ -83,6 +247,10 @@ fn grid_span_2_min_content_auto_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), auto()], ..Default::default() @@ -94,28 +262,162 @@ fn grid_span_2_min_content_auto_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs index 21d635772..027842d60 100644 --- a/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs @@ -4,8 +4,18 @@ fn grid_span_2_min_content_auto_indefinite_hidden__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node0 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node2 = taffy .new_leaf_with_context( taffy::style::Style { @@ -24,6 +34,10 @@ fn grid_span_2_min_content_auto_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), auto()], ..Default::default() @@ -35,48 +49,164 @@ fn grid_span_2_min_content_auto_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -86,10 +216,18 @@ fn grid_span_2_min_content_auto_indefinite_hidden__content_box() { use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node0 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy .new_leaf_with_context( @@ -111,6 +249,10 @@ fn grid_span_2_min_content_auto_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), auto()], ..Default::default() @@ -122,46 +264,162 @@ fn grid_span_2_min_content_auto_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs index 6819a11b7..8fb5b1504 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_min_content_fit_content_10px_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs index 4ff1a6635..074000733 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -37,6 +39,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() @@ -48,48 +54,164 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +223,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -109,6 +232,7 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -135,6 +259,10 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() @@ -146,46 +274,162 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs index 33bd16408..84aa1feb3 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_min_content_fit_content_30px_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs index 98b1bb049..3d4799a3d 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -37,6 +39,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() @@ -48,48 +54,164 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node2, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +223,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -109,6 +232,7 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -135,6 +259,10 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() @@ -146,46 +274,162 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 30f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node2, 70f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs index e6968f1a1..70e978885 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_min_content_fit_content_80px_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs b/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs index 8b2cb386d..07b26eaac 100644 --- a/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -37,6 +39,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() @@ -48,48 +54,164 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +223,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -109,6 +232,7 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -135,6 +259,10 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() @@ -146,46 +274,162 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 40f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node2, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs index 5fb8cc8b4..55ad65048 100644 --- a/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_max_content_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_max_content_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_min_content_max_content_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_min_content_max_content_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), max_content()], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_min_content_max_content_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_min_content_max_content_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_min_content_max_content_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_min_content_max_content_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_min_content_max_content_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), max_content()], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_min_content_max_content_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 60f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 60f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 80f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs b/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs index 872f9ff40..e31a47c21 100644 --- a/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs +++ b/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs @@ -6,6 +6,7 @@ fn grid_span_2_min_content_min_content_indefinite__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -13,6 +14,7 @@ fn grid_span_2_min_content_min_content_indefinite__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -21,6 +23,10 @@ fn grid_span_2_min_content_min_content_indefinite__border_box() { let node2 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -32,6 +38,10 @@ fn grid_span_2_min_content_min_content_indefinite__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), min_content()], ..Default::default() @@ -43,30 +53,164 @@ fn grid_span_2_min_content_min_content_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -78,6 +222,7 @@ fn grid_span_2_min_content_min_content_indefinite__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -86,6 +231,7 @@ fn grid_span_2_min_content_min_content_indefinite__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, ..Default::default() @@ -95,6 +241,10 @@ fn grid_span_2_min_content_min_content_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() @@ -107,6 +257,10 @@ fn grid_span_2_min_content_min_content_indefinite__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32)], grid_template_columns: vec![min_content(), min_content()], ..Default::default() @@ -118,28 +272,162 @@ fn grid_span_2_min_content_min_content_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs b/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs index 054da1665..994e5c357 100644 --- a/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs +++ b/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs @@ -7,22 +7,60 @@ fn grid_span_6_all_non_flex_indefinite__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, ..Default::default() }, crate::TestNodeContext::ahem_text("HHHHHHHH\u{200b}HHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -41,54 +79,320 @@ fn grid_span_6_all_non_flex_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 89f32, "width of node {:?}. Expected {}. Actual {}", node2, 89f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 89f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 99f32, "x of node {:?}. Expected {}. Actual {}", node3, 99f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 99f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node4, 9f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 109f32, "x of node {:?}. Expected {}. Actual {}", node4, 109f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 109f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 109f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -101,6 +405,10 @@ fn grid_span_6_all_non_flex_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, ..Default::default() }, @@ -108,28 +416,56 @@ fn grid_span_6_all_non_flex_indefinite__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -148,52 +484,318 @@ fn grid_span_6_all_non_flex_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 89f32, "width of node {:?}. Expected {}. Actual {}", node2, 89f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 89f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 89f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 99f32, "x of node {:?}. Expected {}. Actual {}", node3, 99f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 99f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node4, 9f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 109f32, "x of node {:?}. Expected {}. Actual {}", node4, 109f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 9f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 9f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 109f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 109f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs b/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs index be9fd0dc6..854815475 100644 --- a/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs +++ b/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs @@ -18,16 +18,50 @@ fn grid_span_6_all_non_flex_indefinite_hidden__border_box() { crate::TestNodeContext::ahem_text("HHHHHHHH\u{200b}HHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -46,72 +80,320 @@ fn grid_span_6_all_non_flex_indefinite_hidden__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 19f32, "width of node {:?}. Expected {}. Actual {}", node1, 19f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 19f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 19f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 99f32, "width of node {:?}. Expected {}. Actual {}", node2, 99f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 19f32, "x of node {:?}. Expected {}. Actual {}", node2, 19f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 99f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 19f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 19f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node3, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node4, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -136,28 +418,56 @@ fn grid_span_6_all_non_flex_indefinite_hidden__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -176,70 +486,318 @@ fn grid_span_6_all_non_flex_indefinite_hidden__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); - #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 19f32, "width of node {:?}. Expected {}. Actual {}", node1, 19f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 19f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 19f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 99f32, "width of node {:?}. Expected {}. Actual {}", node2, 99f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 19f32, "x of node {:?}. Expected {}. Actual {}", node2, 19f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 99f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 99f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 19f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 19f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node3, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node4, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 118f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 118f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 128f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 128f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs b/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs index 2d74ac717..cae7d1814 100644 --- a/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs +++ b/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs @@ -7,24 +7,72 @@ fn grid_span_8_all_track_types_indefinite__border_box() { let node0 = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(8u16) }, ..Default::default() }, crate::TestNodeContext::ahem_text("HHHHHHHH\u{200b}HHHHHHHH", crate::WritingMode::Horizontal), ) .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -45,66 +93,398 @@ fn grid_span_8_all_track_types_indefinite__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node6, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 39f32, "width of node {:?}. Expected {}. Actual {}", node7, 39f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node7, 42f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 39f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 39f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 42f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 79f32, "width of node {:?}. Expected {}. Actual {}", node8, 79f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 81f32, "x of node {:?}. Expected {}. Actual {}", node8, 81f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 79f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 79f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 81f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 81f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -117,6 +497,10 @@ fn grid_span_8_all_track_types_indefinite__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(8u16) }, ..Default::default() }, @@ -124,34 +508,70 @@ fn grid_span_8_all_track_types_indefinite__content_box() { ) .unwrap(); let node1 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(40f32), length(40f32)], grid_template_columns: vec![ min_content(), @@ -172,64 +592,396 @@ fn grid_span_8_all_track_types_indefinite__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 80f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 80f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 160f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 160f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node3).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node3, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node3, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node4).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); + if layout.size.width != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.width), 0f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node4, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node4, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node5).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); + if layout.size.width != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.width), 10f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node5, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node5, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node6).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); - assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node6, 10f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); + if layout.size.width != 32f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.width), 32f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.x), 10f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node6, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node6, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node7).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 39f32, "width of node {:?}. Expected {}. Actual {}", node7, 39f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); - assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node7, 42f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); + if layout.size.width != 39f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.width), 39f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 42f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.x), 42f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node7, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node7, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node8).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 79f32, "width of node {:?}. Expected {}. Actual {}", node8, 79f32, size.width); - assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); - assert_eq!(location.x, 81f32, "x of node {:?}. Expected {}. Actual {}", node8, 81f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); + if layout.size.width != 79f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.width), 79f32, layout.size.width); + } + if layout.size.height != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(size.height), 40f32, layout.size.height); + } + if layout.location.x != 81f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.x), 81f32, layout.location.x); + } + if layout.location.y != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node8, stringify!(location.y), 40f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node8, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/grid_taffy_issue_624.rs b/tests/generated/grid/grid_taffy_issue_624.rs index 81b676ae1..f6be8c47f 100644 --- a/tests/generated/grid/grid_taffy_issue_624.rs +++ b/tests/generated/grid/grid_taffy_issue_624.rs @@ -6,6 +6,7 @@ fn grid_taffy_issue_624__border_box() { let mut taffy = crate::new_test_tree(); let node0 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -17,6 +18,7 @@ fn grid_taffy_issue_624__border_box() { .unwrap(); let node1 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Span(2u16) }, size: taffy::geometry::Size { @@ -28,6 +30,7 @@ fn grid_taffy_issue_624__border_box() { .unwrap(); let node2 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Span(1u16) }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, size: taffy::geometry::Size { @@ -41,6 +44,10 @@ fn grid_taffy_issue_624__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Start), justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![auto(), auto(), auto(), fr(1f32)], @@ -58,30 +65,164 @@ fn grid_taffy_issue_624__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 640f32, "height of node {:?}. Expected {}. Actual {}", node, 640f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 640f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 640f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node2, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -93,6 +234,7 @@ fn grid_taffy_issue_624__content_box() { let node0 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, size: taffy::geometry::Size { @@ -105,6 +247,7 @@ fn grid_taffy_issue_624__content_box() { let node1 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Span(2u16) }, size: taffy::geometry::Size { @@ -117,6 +260,7 @@ fn grid_taffy_issue_624__content_box() { let node2 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Span(1u16) }, grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, size: taffy::geometry::Size { @@ -131,6 +275,10 @@ fn grid_taffy_issue_624__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, justify_items: Some(taffy::style::JustifyItems::Start), justify_content: Some(taffy::style::JustifyContent::Start), grid_template_rows: vec![auto(), auto(), auto(), fr(1f32)], @@ -148,28 +296,162 @@ fn grid_taffy_issue_624__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); - assert_eq!(size.height, 640f32, "height of node {:?}. Expected {}. Actual {}", node, 640f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 320f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 320f32, layout.size.width); + } + if layout.size.height != 640f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 640f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 50f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node1).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); - assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); - assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 30f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(size.height), 30f32, layout.size.height); + } + if layout.location.x != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.x), 100f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node1, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node1, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node2).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node2, 120f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); - assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); + if layout.size.width != 120f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.width), 120f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node2, stringify!(location.y), 50f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node2, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/grid/mod.rs b/tests/generated/grid/mod.rs index f2f16558b..02cc566bb 100644 --- a/tests/generated/grid/mod.rs +++ b/tests/generated/grid/mod.rs @@ -34,6 +34,14 @@ mod grid_absolute_layout_within_border; #[cfg(feature = "grid")] mod grid_absolute_layout_within_border_static; #[cfg(feature = "grid")] +mod grid_absolute_overflow_clip; +#[cfg(feature = "grid")] +mod grid_absolute_overflow_hidden; +#[cfg(feature = "grid")] +mod grid_absolute_overflow_scroll; +#[cfg(feature = "grid")] +mod grid_absolute_overflow_visible; +#[cfg(feature = "grid")] mod grid_absolute_resolved_insets; #[cfg(feature = "grid")] mod grid_absolute_row_end; @@ -236,6 +244,14 @@ mod grid_gap; #[cfg(feature = "grid")] mod grid_hidden; #[cfg(feature = "grid")] +mod grid_inflow_overflow_clip; +#[cfg(feature = "grid")] +mod grid_inflow_overflow_hidden; +#[cfg(feature = "grid")] +mod grid_inflow_overflow_scroll; +#[cfg(feature = "grid")] +mod grid_inflow_overflow_visible; +#[cfg(feature = "grid")] mod grid_justify_content_center; #[cfg(feature = "grid")] mod grid_justify_content_center_negative_space_gap; diff --git a/tests/generated/gridflex/gridflex_column_integration.rs b/tests/generated/gridflex/gridflex_column_integration.rs index 3ff007c4a..47f55210a 100644 --- a/tests/generated/gridflex/gridflex_column_integration.rs +++ b/tests/generated/gridflex/gridflex_column_integration.rs @@ -6,25 +6,49 @@ fn gridflex_column_integration__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -32,6 +56,10 @@ fn gridflex_column_integration__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -41,7 +69,14 @@ fn gridflex_column_integration__border_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -49,42 +84,266 @@ fn gridflex_column_integration__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -95,25 +354,53 @@ fn gridflex_column_integration__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -122,6 +409,10 @@ fn gridflex_column_integration__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -134,6 +425,10 @@ fn gridflex_column_integration__content_box() { taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, ..Default::default() }, &[node0], @@ -143,40 +438,264 @@ fn gridflex_column_integration__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/gridflex/gridflex_kitchen_sink.rs b/tests/generated/gridflex/gridflex_kitchen_sink.rs index 4fe9a0921..1e353598b 100644 --- a/tests/generated/gridflex/gridflex_kitchen_sink.rs +++ b/tests/generated/gridflex/gridflex_kitchen_sink.rs @@ -6,23 +6,44 @@ fn gridflex_kitchen_sink__border_box() { let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node00100 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); - let node00101 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node00102 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node00103 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node00101 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node00102 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node00103 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0010 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() @@ -33,6 +54,10 @@ fn gridflex_kitchen_sink__border_box() { let node001 = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -40,22 +65,51 @@ fn gridflex_kitchen_sink__border_box() { &[node0010], ) .unwrap(); - let node00 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node000, node001]).unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node000, node001], + ) + .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -63,6 +117,10 @@ fn gridflex_kitchen_sink__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -70,89 +128,675 @@ fn gridflex_kitchen_sink__border_box() { &[node00, node01, node02, node03], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node001, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node001, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0010, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0010, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00100, 20f32, size.width); - assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00100, 3f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.height), + 3f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00101, 2f32, size.width); - assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00101, 3f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00101, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.width), + 2f32, + layout.size.width + ); + } + if layout.size.height != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.height), + 3f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.x), + 20f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00102).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00102, 20f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00102, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00102, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00102, 3f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(size.height), + 1f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(location.y), + 3f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00103).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00103, 2f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00103, 1f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00103, 20f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00103, 3f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(size.width), + 2f32, + layout.size.width + ); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(size.height), + 1f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(location.x), + 20f32, + layout.location.x + ); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(location.y), + 3f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node01, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node01, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node02, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node03, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node03, 70f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -164,6 +808,7 @@ fn gridflex_kitchen_sink__content_box() { let node000 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) @@ -171,24 +816,41 @@ fn gridflex_kitchen_sink__content_box() { let node00100 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() }, ..Default::default() }) .unwrap(); let node00101 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00102 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node00103 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0010 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() @@ -200,6 +862,10 @@ fn gridflex_kitchen_sink__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -209,25 +875,53 @@ fn gridflex_kitchen_sink__content_box() { .unwrap(); let node00 = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node000, node001], ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -236,6 +930,10 @@ fn gridflex_kitchen_sink__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -245,7 +943,14 @@ fn gridflex_kitchen_sink__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -253,82 +958,657 @@ fn gridflex_kitchen_sink__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 140f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 140f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node000).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node000, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node000, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node001).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node001, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node001, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node001, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node001, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0010).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0010, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0010, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0010, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0010, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0010, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00100).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00100, 20f32, size.width); - assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00100, 3f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(size.height), + 3f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00100, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00101).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00101, 2f32, size.width); - assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00101, 3f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00101, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.width), + 2f32, + layout.size.width + ); + } + if layout.size.height != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(size.height), + 3f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.x), + 20f32, + layout.location.x + ); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(location.y), + 0f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00101, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00102).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00102, 20f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00102, 1f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00102, 0f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00102, 3f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(size.width), + 20f32, + layout.size.width + ); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(size.height), + 1f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(location.x), + 0f32, + layout.location.x + ); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(location.y), + 3f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00102, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00103).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00103, 2f32, size.width); - assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00103, 1f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00103, 20f32, location.x); - assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00103, 3f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(size.width), + 2f32, + layout.size.width + ); + } + if layout.size.height != 1f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(size.height), + 1f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(location.x), + 20f32, + layout.location.x + ); + } + if layout.location.y != 3f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(location.y), + 3f32, + layout.location.y + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00103, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node01, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node01, 70f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node02, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node03, 70f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node03, 70f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 70f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 70f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 70f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs b/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs index e375ba110..0c8e7324a 100644 --- a/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs +++ b/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs @@ -6,15 +6,25 @@ fn gridflex_kitchen_sink_minimise__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(20f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -22,35 +32,192 @@ fn gridflex_kitchen_sink_minimise__border_box() { &[node00, node01], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -62,18 +229,27 @@ fn gridflex_kitchen_sink_minimise__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![length(20f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -83,7 +259,14 @@ fn gridflex_kitchen_sink_minimise__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -91,28 +274,174 @@ fn gridflex_kitchen_sink_minimise__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 100f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 100f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 50f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs b/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs index bb46877c1..20efd048a 100644 --- a/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs +++ b/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs @@ -6,6 +6,7 @@ fn gridflex_kitchen_sink_minimise2__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -17,6 +18,10 @@ fn gridflex_kitchen_sink_minimise2__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![auto()], grid_template_columns: vec![auto()], ..Default::default() @@ -27,6 +32,10 @@ fn gridflex_kitchen_sink_minimise2__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -38,24 +47,131 @@ fn gridflex_kitchen_sink_minimise2__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,6 +183,7 @@ fn gridflex_kitchen_sink_minimise2__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -79,6 +196,10 @@ fn gridflex_kitchen_sink_minimise2__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![auto()], grid_template_columns: vec![auto()], ..Default::default() @@ -90,6 +211,10 @@ fn gridflex_kitchen_sink_minimise2__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() @@ -101,22 +226,129 @@ fn gridflex_kitchen_sink_minimise2__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs b/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs index a3f301242..1b890acd9 100644 --- a/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs +++ b/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs @@ -6,6 +6,7 @@ fn gridflex_kitchen_sink_minimise3__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -13,13 +14,32 @@ fn gridflex_kitchen_sink_minimise3__border_box() { ..Default::default() }) .unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node01 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node02 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); + let node03 = taffy + .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) + .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() @@ -30,6 +50,10 @@ fn gridflex_kitchen_sink_minimise3__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -40,42 +64,248 @@ fn gridflex_kitchen_sink_minimise3__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node01, 6f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 6f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node02, 2f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 6f32, "y of node {:?}. Expected {}. Actual {}", node02, 6f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 2f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node03, 2f32, size.width); - assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node03, 2f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 6f32, "y of node {:?}. Expected {}. Actual {}", node03, 6f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 2f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -87,6 +317,7 @@ fn gridflex_kitchen_sink_minimise3__content_box() { let node00 = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: taffy::style::Dimension::from_length(20f32), @@ -95,19 +326,35 @@ fn gridflex_kitchen_sink_minimise3__content_box() { }) .unwrap(); let node01 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node02 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node03 = taffy - .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }) + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() @@ -119,6 +366,10 @@ fn gridflex_kitchen_sink_minimise3__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() }, ..Default::default() }, @@ -129,40 +380,246 @@ fn gridflex_kitchen_sink_minimise3__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 50f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 50f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 2f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 2f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 20f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); - assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node01, 6f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.height), 6f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node02, 2f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 6f32, "y of node {:?}. Expected {}. Actual {}", node02, 6f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.height), 2f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node03, 2f32, size.width); - assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node03, 2f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 6f32, "y of node {:?}. Expected {}. Actual {}", node03, 6f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.height), 2f32, layout.size.height); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 6f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 6f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/gridflex/gridflex_row_integration.rs b/tests/generated/gridflex/gridflex_row_integration.rs index 910003e57..4dae177f0 100644 --- a/tests/generated/gridflex/gridflex_row_integration.rs +++ b/tests/generated/gridflex/gridflex_row_integration.rs @@ -6,25 +6,49 @@ fn gridflex_row_integration__border_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { ..Default::default() }, + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -32,6 +56,10 @@ fn gridflex_row_integration__border_box() { .new_with_children( taffy::style::Style { display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -39,47 +67,282 @@ fn gridflex_row_integration__border_box() { &[node00, node01, node02, node03], ) .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -90,25 +353,53 @@ fn gridflex_row_integration__content_box() { let mut taffy = crate::new_test_tree(); let node00 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node01 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node02 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); let node03 = taffy .new_leaf_with_context( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal), ) .unwrap(); @@ -117,6 +408,10 @@ fn gridflex_row_integration__content_box() { taffy::style::Style { display: taffy::style::Display::Grid, box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, grid_template_rows: vec![fr(1f32), fr(1f32)], grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() @@ -126,7 +421,14 @@ fn gridflex_row_integration__content_box() { .unwrap(); let node = taffy .new_with_children( - taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() }, + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + ..Default::default() + }, &[node0], ) .unwrap(); @@ -134,40 +436,264 @@ fn gridflex_row_integration__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); - assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 40f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 40f32, layout.size.width); + } + if layout.size.height != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 20f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node00).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node00, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node00, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node01).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node01, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node01, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node02).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node02, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node02, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node03).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); - assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node03, 10f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(size.height), + 10f32, + layout.size.height + ); + } + if layout.location.x != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.x), 20f32, layout.location.x); + } + if layout.location.y != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node03, stringify!(location.y), 10f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node03, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_clip.rs b/tests/generated/leaf/leaf_overflow_clip.rs new file mode 100644 index 000000000..59b87ffee --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_clip.rs @@ -0,0 +1,134 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_clip_with_border.rs b/tests/generated/leaf/leaf_overflow_clip_with_border.rs new file mode 100644 index 000000000..89b5e4dc4 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_clip_with_border.rs @@ -0,0 +1,146 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_border__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 171f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 171f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 29f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 29f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_border__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_clip_with_border_and_padding.rs b/tests/generated/leaf/leaf_overflow_clip_with_border_and_padding.rs new file mode 100644 index 000000000..b63f8327a --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_clip_with_border_and_padding.rs @@ -0,0 +1,160 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_border_and_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 183f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 183f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 33f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 33f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_border_and_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 161f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 161f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 19f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 19f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_clip_with_padding.rs b/tests/generated/leaf/leaf_overflow_clip_with_padding.rs new file mode 100644 index 000000000..5ec3197c1 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_clip_with_padding.rs @@ -0,0 +1,148 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 169f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 169f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 26f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_clip_with_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Clip, y: taffy::style::Overflow::Clip }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 163f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 163f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 22f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_hidden.rs b/tests/generated/leaf/leaf_overflow_hidden.rs new file mode 100644 index 000000000..ae12d0ec5 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_hidden.rs @@ -0,0 +1,142 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_hidden_with_border.rs b/tests/generated/leaf/leaf_overflow_hidden_with_border.rs new file mode 100644 index 000000000..b7e55993c --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_hidden_with_border.rs @@ -0,0 +1,154 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_border__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 171f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 171f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 29f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 29f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_border__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_hidden_with_border_and_padding.rs b/tests/generated/leaf/leaf_overflow_hidden_with_border_and_padding.rs new file mode 100644 index 000000000..cdff61f6d --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_hidden_with_border_and_padding.rs @@ -0,0 +1,168 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_border_and_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 187f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 187f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 39f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 39f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_border_and_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_hidden_with_padding.rs b/tests/generated/leaf/leaf_overflow_hidden_with_padding.rs new file mode 100644 index 000000000..f13544637 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_hidden_with_padding.rs @@ -0,0 +1,156 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 171f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 171f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 29f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 29f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_hidden_with_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_scroll.rs b/tests/generated/leaf/leaf_overflow_scroll.rs new file mode 100644 index 000000000..938a9d791 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_scroll.rs @@ -0,0 +1,142 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_scroll_with_border.rs b/tests/generated/leaf/leaf_overflow_scroll_with_border.rs new file mode 100644 index 000000000..e711a6de8 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_scroll_with_border.rs @@ -0,0 +1,154 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_border__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 186f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 186f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_border__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_scroll_with_border_and_padding.rs b/tests/generated/leaf/leaf_overflow_scroll_with_border_and_padding.rs new file mode 100644 index 000000000..ec2b987a5 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_scroll_with_border_and_padding.rs @@ -0,0 +1,168 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_border_and_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 202f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 202f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 54f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 54f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_border_and_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_scroll_with_padding.rs b/tests/generated/leaf/leaf_overflow_scroll_with_padding.rs new file mode 100644 index 000000000..5f2300a2c --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_scroll_with_padding.rs @@ -0,0 +1,156 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 186f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 186f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 44f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 44f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_scroll_with_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 40f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 40f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs b/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs index e622efa33..221c793ca 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs @@ -25,30 +25,47 @@ fn leaf_overflow_scrollbars_affect_available_space_x_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 165f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 165f32, - layout.scroll_width() - ); + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,28 +96,45 @@ fn leaf_overflow_scrollbars_affect_available_space_x_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 165f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 165f32, - layout.scroll_width() - ); + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs b/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs index 965360175..b92c6f68f 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs @@ -25,30 +25,47 @@ fn leaf_overflow_scrollbars_affect_available_space_y_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 180f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 180f32, - layout.scroll_width() - ); + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,28 +96,45 @@ fn leaf_overflow_scrollbars_affect_available_space_y_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); - assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 180f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 180f32, - layout.scroll_width() - ); + if layout.scroll_width() != 180f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 180f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs index 06c9f8dec..bfb50a120 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs @@ -15,6 +15,10 @@ fn leaf_overflow_scrollbars_overridden_by_available_space__border_box() { let node = taffy .new_with_children( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -28,36 +32,86 @@ fn leaf_overflow_scrollbars_overridden_by_available_space__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -79,6 +133,10 @@ fn leaf_overflow_scrollbars_overridden_by_available_space__content_box() { .new_with_children( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(2f32), height: taffy::style::Dimension::from_length(4f32), @@ -92,34 +150,84 @@ fn leaf_overflow_scrollbars_overridden_by_available_space__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node0, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node0, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node0, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs index b1abf7d05..b55a32352 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs @@ -19,30 +19,47 @@ fn leaf_overflow_scrollbars_overridden_by_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,28 +84,45 @@ fn leaf_overflow_scrollbars_overridden_by_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs index f7d8095d8..f2b9f0d71 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs @@ -19,30 +19,47 @@ fn leaf_overflow_scrollbars_overridden_by_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -67,28 +84,45 @@ fn leaf_overflow_scrollbars_overridden_by_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); - assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 2f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 2f32, layout.size.width); + } + if layout.size.height != 4f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 4f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs index 0ddfc513a..8851778f7 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs @@ -21,30 +21,47 @@ fn leaf_overflow_scrollbars_take_up_space_both_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,28 +88,45 @@ fn leaf_overflow_scrollbars_take_up_space_both_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs index d82524e71..6f8d0ca88 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs @@ -21,30 +21,47 @@ fn leaf_overflow_scrollbars_take_up_space_x_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,28 +88,45 @@ fn leaf_overflow_scrollbars_take_up_space_x_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); - assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 20f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 20f32, layout.size.width); + } + if layout.size.height != 25f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 25f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs index 2b9902d03..6f56e19d7 100644 --- a/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs +++ b/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs @@ -21,30 +21,47 @@ fn leaf_overflow_scrollbars_take_up_space_y_axis__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -71,28 +88,45 @@ fn leaf_overflow_scrollbars_take_up_space_y_axis__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); - assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 35f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 35f32, layout.size.width); + } + if layout.size.height != 10f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 10f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_width(), - 0f32, - "scroll_width of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_width() - ); + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } #[cfg(feature = "content_size")] - assert_eq!( - layout.scroll_height(), - 0f32, - "scroll_height of node {:?}. Expected {}. Actual {}", - node, - 0f32, - layout.scroll_height() - ); + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_overflow_visible.rs b/tests/generated/leaf/leaf_overflow_visible.rs new file mode 100644 index 000000000..f67560a32 --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_visible.rs @@ -0,0 +1,140 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_visible_with_border.rs b/tests/generated/leaf/leaf_overflow_visible_with_border.rs new file mode 100644 index 000000000..baf69c77a --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_visible_with_border.rs @@ -0,0 +1,152 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_border__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 171f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 171f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 29f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 29f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_border__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + border: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 165f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 165f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 25f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 25f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_visible_with_border_and_padding.rs b/tests/generated/leaf/leaf_overflow_visible_with_border_and_padding.rs new file mode 100644 index 000000000..9e1c7d77b --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_visible_with_border_and_padding.rs @@ -0,0 +1,166 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_border_and_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 183f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 183f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 33f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 33f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_border_and_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(8f32), + right: length(4f32), + top: length(2f32), + bottom: length(6f32), + }, + border: taffy::geometry::Rect { + left: length(7f32), + right: length(3f32), + top: length(1f32), + bottom: length(5f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 67f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 67f32, layout.size.width); + } + if layout.size.height != 59f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 59f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 161f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 161f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 19f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 19f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_overflow_visible_with_padding.rs b/tests/generated/leaf/leaf_overflow_visible_with_padding.rs new file mode 100644 index 000000000..f9c94ebce --- /dev/null +++ b/tests/generated/leaf/leaf_overflow_visible_with_padding.rs @@ -0,0 +1,154 @@ +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_padding__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 45f32, layout.size.width); + } + if layout.size.height != 45f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 45f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 169f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 169f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 26f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 26f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} + +#[test] +#[allow(non_snake_case)] +fn leaf_overflow_visible_with_padding__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node_text = "HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHHHHHHH" ; + let node = taffy + .new_leaf_with_context( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(45f32), + height: taffy::style::Dimension::from_length(45f32), + }, + padding: taffy::geometry::Rect { + left: length(4f32), + right: length(2f32), + top: length(1f32), + bottom: length(3f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text(node_text, crate::WritingMode::Horizontal), + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let mut mismatches = 0u32; + let layout = taffy.layout(node).unwrap(); + if layout.size.width != 51f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 51f32, layout.size.width); + } + if layout.size.height != 49f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 49f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 163f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 163f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 22f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 22f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); +} diff --git a/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs b/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs index 4637fd509..9c5255536 100644 --- a/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs +++ b/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs @@ -6,6 +6,7 @@ fn leaf_padding_border_overrides_max_size__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -29,12 +30,47 @@ fn leaf_padding_border_overrides_max_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +82,7 @@ fn leaf_padding_border_overrides_max_size__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -69,10 +106,45 @@ fn leaf_padding_border_overrides_max_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs b/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs index b9633ff82..dda1e221c 100644 --- a/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs +++ b/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs @@ -6,6 +6,7 @@ fn leaf_padding_border_overrides_min_size__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -29,12 +30,47 @@ fn leaf_padding_border_overrides_min_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +82,7 @@ fn leaf_padding_border_overrides_min_size__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(0f32), height: taffy::style::Dimension::from_length(0f32), @@ -69,10 +106,45 @@ fn leaf_padding_border_overrides_min_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_padding_border_overrides_size.rs b/tests/generated/leaf/leaf_padding_border_overrides_size.rs index 5d211789e..fb1cd36f8 100644 --- a/tests/generated/leaf/leaf_padding_border_overrides_size.rs +++ b/tests/generated/leaf/leaf_padding_border_overrides_size.rs @@ -6,6 +6,7 @@ fn leaf_padding_border_overrides_size__border_box() { let mut taffy = crate::new_test_tree(); let node = taffy .new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -29,12 +30,47 @@ fn leaf_padding_border_overrides_size__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); - assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 22f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 22f32, layout.size.width); + } + if layout.size.height != 14f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 14f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +82,7 @@ fn leaf_padding_border_overrides_size__content_box() { let node = taffy .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Visible }, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(12f32), height: taffy::style::Dimension::from_length(12f32), @@ -69,10 +106,45 @@ fn leaf_padding_border_overrides_size__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); - assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node, 26f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 34f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 34f32, layout.size.width); + } + if layout.size.height != 26f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 26f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_with_content_and_border.rs b/tests/generated/leaf/leaf_with_content_and_border.rs index bb8504420..8c1d35f50 100644 --- a/tests/generated/leaf/leaf_with_content_and_border.rs +++ b/tests/generated/leaf/leaf_with_content_and_border.rs @@ -7,6 +7,10 @@ fn leaf_with_content_and_border__border_box() { let node = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -22,12 +26,47 @@ fn leaf_with_content_and_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -40,6 +79,10 @@ fn leaf_with_content_and_border__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, border: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -55,10 +98,45 @@ fn leaf_with_content_and_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_with_content_and_padding.rs b/tests/generated/leaf/leaf_with_content_and_padding.rs index 96365ae73..a75b56fa5 100644 --- a/tests/generated/leaf/leaf_with_content_and_padding.rs +++ b/tests/generated/leaf/leaf_with_content_and_padding.rs @@ -7,6 +7,10 @@ fn leaf_with_content_and_padding__border_box() { let node = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -22,12 +26,47 @@ fn leaf_with_content_and_padding__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -40,6 +79,10 @@ fn leaf_with_content_and_padding__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -55,10 +98,45 @@ fn leaf_with_content_and_padding__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); - assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 52f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 52f32, layout.size.width); + } + if layout.size.height != 18f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 18f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/leaf_with_content_and_padding_border.rs b/tests/generated/leaf/leaf_with_content_and_padding_border.rs index 51019a900..a9cc0d2e3 100644 --- a/tests/generated/leaf/leaf_with_content_and_padding_border.rs +++ b/tests/generated/leaf/leaf_with_content_and_padding_border.rs @@ -7,6 +7,10 @@ fn leaf_with_content_and_padding_border__border_box() { let node = taffy .new_leaf_with_context( taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -28,12 +32,47 @@ fn leaf_with_content_and_padding_border__border_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } #[test] @@ -46,6 +85,10 @@ fn leaf_with_content_and_padding_border__content_box() { .new_leaf_with_context( taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Visible, + }, padding: taffy::geometry::Rect { left: length(8f32), right: length(4f32), @@ -67,10 +110,45 @@ fn leaf_with_content_and_padding_border__content_box() { println!("\nComputed tree:"); taffy.print_tree(node); println!(); + let mut mismatches = 0u32; let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); - assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node, 24f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + if layout.size.width != 62f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.width), 62f32, layout.size.width); + } + if layout.size.height != 24f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(size.height), 24f32, layout.size.height); + } + if layout.location.x != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.x), 0f32, layout.location.x); + } + if layout.location.y != 0f32 { + mismatches += 1; + eprintln!("{:?}.{} mismatch: expected {} actual {}", node, stringify!(location.y), 0f32, layout.location.y); + } + #[cfg(feature = "content_size")] + if layout.scroll_width() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_width()), + 0f32, + layout.scroll_width() + ); + } + #[cfg(feature = "content_size")] + if layout.scroll_height() != 0f32 { + mismatches += 1; + eprintln!( + "{:?}.{} mismatch: expected {} actual {}", + node, + stringify!(scroll_height()), + 0f32, + layout.scroll_height() + ); + } + assert!(mismatches == 0, "Detected {mismatches} mismatch(es)"); } diff --git a/tests/generated/leaf/mod.rs b/tests/generated/leaf/mod.rs index 161131924..1b5608a83 100644 --- a/tests/generated/leaf/mod.rs +++ b/tests/generated/leaf/mod.rs @@ -1,3 +1,15 @@ +mod leaf_overflow_clip; +mod leaf_overflow_clip_with_border; +mod leaf_overflow_clip_with_border_and_padding; +mod leaf_overflow_clip_with_padding; +mod leaf_overflow_hidden; +mod leaf_overflow_hidden_with_border; +mod leaf_overflow_hidden_with_border_and_padding; +mod leaf_overflow_hidden_with_padding; +mod leaf_overflow_scroll; +mod leaf_overflow_scroll_with_border; +mod leaf_overflow_scroll_with_border_and_padding; +mod leaf_overflow_scroll_with_padding; mod leaf_overflow_scrollbars_affect_available_space_x_axis; mod leaf_overflow_scrollbars_affect_available_space_y_axis; mod leaf_overflow_scrollbars_overridden_by_available_space; @@ -6,6 +18,10 @@ mod leaf_overflow_scrollbars_overridden_by_size; mod leaf_overflow_scrollbars_take_up_space_both_axis; mod leaf_overflow_scrollbars_take_up_space_x_axis; mod leaf_overflow_scrollbars_take_up_space_y_axis; +mod leaf_overflow_visible; +mod leaf_overflow_visible_with_border; +mod leaf_overflow_visible_with_border_and_padding; +mod leaf_overflow_visible_with_padding; mod leaf_padding_border_overrides_max_size; mod leaf_padding_border_overrides_min_size; mod leaf_padding_border_overrides_size;